mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
Fixed #122 -- BIG, BACKWARDS-INCOMPATIBLE CHANGE. Changed model syntax to use fieldname=FieldClass() syntax. See ModelSyntaxChangeInstructions for important information on how to change your models
git-svn-id: http://code.djangoproject.com/svn/django/trunk@549 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
aec0a73d73
commit
25264c8604
36 changed files with 956 additions and 720 deletions
|
@ -21,20 +21,16 @@ offers many rich ways of representing your models -- so far, it's been
|
|||
solving two years' worth of database-schema problems. Here's a quick example::
|
||||
|
||||
class Reporter(meta.Model):
|
||||
fields = (
|
||||
meta.CharField('full_name', maxlength=70),
|
||||
)
|
||||
full_name = meta.CharField(maxlength=70)
|
||||
|
||||
def __repr__(self):
|
||||
return self.full_name
|
||||
|
||||
class Article(meta.Model):
|
||||
fields = (
|
||||
meta.DateTimeField('pub_date'),
|
||||
meta.CharField('headline', maxlength=200),
|
||||
meta.TextField('article'),
|
||||
meta.ForeignKey(Reporter),
|
||||
)
|
||||
pub_date = meta.DateTimeField('pub_date')
|
||||
headline = meta.CharField('headline', maxlength=200)
|
||||
article = meta.TextField('article')
|
||||
reporter = meta.ForeignKey(Reporter)
|
||||
|
||||
def __repr__(self):
|
||||
return self.headline
|
||||
|
@ -134,17 +130,16 @@ A dynamic admin interface: It's not just scaffolding -- it's the whole house
|
|||
|
||||
Once your models are defined, Django can automatically create an administrative
|
||||
interface -- a Web site that lets authenticated users add, change and
|
||||
delete objects. It's as easy as adding an extra admin attribute to your model
|
||||
classes::
|
||||
delete objects. It's as easy as adding an extra ``admin`` attribute to your
|
||||
model classes::
|
||||
|
||||
class Article(meta.Model):
|
||||
fields = (
|
||||
meta.DateTimeField('pub_date'),
|
||||
meta.CharField('headline', maxlength=200),
|
||||
meta.TextField('article'),
|
||||
meta.ForeignKey(Reporter),
|
||||
)
|
||||
admin = meta.Admin()
|
||||
pub_date = meta.DateTimeField('pub_date')
|
||||
headline = meta.CharField('headline', maxlength=200)
|
||||
article = meta.TextField('article')
|
||||
reporter = meta.ForeignKey(Reporter)
|
||||
class META:
|
||||
admin = meta.Admin()
|
||||
|
||||
The philosophy here is that your site is edited by a staff, or a client, or
|
||||
maybe just you -- and you don't want to have to deal with creating backend
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue