1
0
mirror of https://github.com/django/django.git synced 2025-06-08 13:09:13 +00:00

fixing modelforms example code, ticket #18832

This commit is contained in:
Nick Martini 2012-09-08 12:30:41 -04:00
parent b7d3b057f3
commit 571698997f

View File

@ -311,18 +311,18 @@ model fields:
to exclude from the form. to exclude from the form.
For example, if you want a form for the ``Author`` model (defined For example, if you want a form for the ``Author`` model (defined
above) that includes only the ``name`` and ``title`` fields, you would above) that includes only the ``name`` and ``birth_date`` fields, you would
specify ``fields`` or ``exclude`` like this:: specify ``fields`` or ``exclude`` like this::
class PartialAuthorForm(ModelForm): class PartialAuthorForm(ModelForm):
class Meta: class Meta:
model = Author model = Author
fields = ('name', 'title') fields = ('name', 'birth_date')
class PartialAuthorForm(ModelForm): class PartialAuthorForm(ModelForm):
class Meta: class Meta:
model = Author model = Author
exclude = ('birth_date',) exclude = ('title',)
Since the Author model has only 3 fields, 'name', 'title', and Since the Author model has only 3 fields, 'name', 'title', and
'birth_date', the forms above will contain exactly the same fields. 'birth_date', the forms above will contain exactly the same fields.