diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2005-07-21 03:46:16 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2005-07-21 03:46:16 +0000 |
| commit | c21f6ecee24c6587bb8ddddc878aad3fd29b40a7 (patch) | |
| tree | c419bdcc72c6e001a58dda127035474cf1800973 /docs/tutorial02.txt | |
| parent | 304b08e3254f7c46999d1204ce9968c00ad088eb (diff) | |
Fixed #92 -- meta.Admin 'fields' parameter is now optional. If it's not given, Django will use all editable fields by default. This cuts down on redundancy. Also updated relevant docs to reflect the change.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@265 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/tutorial02.txt')
| -rw-r--r-- | docs/tutorial02.txt | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/docs/tutorial02.txt b/docs/tutorial02.txt index 0c96c5c12d..7c03c71c1f 100644 --- a/docs/tutorial02.txt +++ b/docs/tutorial02.txt @@ -92,11 +92,7 @@ file and make the following change to add an ``admin`` attribute:: fields = ( # ... ) - admin = meta.Admin( - fields = ( - (None, {'fields': ('question', 'pub_date')}), - ), - ) + admin = meta.Admin() Restart your development Web server, and reload the Django admin page. You'll have to restart the server each time you make a change to Python code -- but @@ -163,8 +159,8 @@ Customize the admin form Take a few minutes to marvel at all the code you didn't have to write. -Let's customize this a bit. We can reorder the fields by changing the -order of the field names in the ``admin`` attribute of the model:: +Let's customize this a bit. We can reorder the fields by explicitly adding a +``fields`` parameter to ``meta.Admin``:: admin = meta.Admin( fields = ( @@ -226,15 +222,7 @@ Here's what that would look like:: class Choice(meta.Model): # ... - admin = meta.Admin( - fields = ( - (None, {'fields': ('poll_id', 'choice', 'votes')}), - ), - ) - -(Note that we used "poll_id" to refer to the ``ForeignKey(Poll)`` field. The -field name is automatically calculated from the model's class name, lowercased, -plus '_id'.) + admin = meta.Admin() Now "Choices" is an available option in the Django admin. The "Add choice" form looks like this: @@ -318,9 +306,6 @@ on the change list page for the object:: class Poll(meta.Model): # ... admin = meta.Admin( - fields = ( - (None, {'fields': ('question', 'pub_date')}), - ), list_display = ('question', 'pub_date'), ) |
