summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Bennett <ubernostrum@gmail.com>2008-03-11 06:40:50 +0000
committerJames Bennett <ubernostrum@gmail.com>2008-03-11 06:40:50 +0000
commit866d7fa961702353443edbaaeb253b823c77f6a7 (patch)
tree15d7725fa4c86df2af4e47e4345d332b4005a73f
parent42712048d363532469cbeff1b0b6a1734c5be5fe (diff)
Correct an example in docs/modelforms.txt, and fix some reST formatting
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7222 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--docs/modelforms.txt48
1 files changed, 24 insertions, 24 deletions
diff --git a/docs/modelforms.txt b/docs/modelforms.txt
index 853fb3159e..a6babb1fe1 100644
--- a/docs/modelforms.txt
+++ b/docs/modelforms.txt
@@ -226,7 +226,7 @@ For example::
# Create a form instance with POST data.
>>> a = Author()
- >>> f = AuthorForm(a, request.POST)
+ >>> f = AuthorForm(request.POST, instance=a)
# Create and save the new author instance. There's no need to do anything else.
>>> new_author = f.save()
@@ -238,34 +238,34 @@ In some cases, you may not want all the model fields to appear on the generated
form. There are three ways of telling ``ModelForm`` to use only a subset of the
model fields:
- 1. Set ``editable=False`` on the model field. As a result, *any* form
- created from the model via ``ModelForm`` will not include that
- field.
+1. Set ``editable=False`` on the model field. As a result, *any* form
+ created from the model via ``ModelForm`` will not include that
+ field.
- 2. Use the ``fields`` attribute of the ``ModelForm``'s inner ``Meta`` class.
- This attribute, if given, should be a list of field names to include in
- the form.
+2. Use the ``fields`` attribute of the ``ModelForm``'s inner ``Meta``
+ class. This attribute, if given, should be a list of field names
+ to include in the form.
- 3. Use the ``exclude`` attribute of the ``ModelForm``'s inner ``Meta`` class.
- This attribute, if given, should be a list of field names to exclude
- the form.
+3. Use the ``exclude`` attribute of the ``ModelForm``'s inner ``Meta``
+ class. This attribute, if given, should be a list of field names
+ to exclude the form.
- For example, if you want a form for the ``Author`` model (defined above)
- that includes only the ``name`` and ``title`` fields, you would specify
- ``fields`` or ``exclude`` like this::
+For example, if you want a form for the ``Author`` model (defined
+above) that includes only the ``name`` and ``title`` fields, you would
+specify ``fields`` or ``exclude`` like this::
- class PartialAuthorForm(ModelForm):
- class Meta:
- model = Author
- fields = ('name', 'title')
-
- class PartialAuthorForm(ModelForm):
- class Meta:
- model = Author
- exclude = ('birth_date',)
+ class PartialAuthorForm(ModelForm):
+ class Meta:
+ model = Author
+ fields = ('name', 'title')
+
+ class PartialAuthorForm(ModelForm):
+ class Meta:
+ model = Author
+ exclude = ('birth_date',)
- Since the Author model has only 3 fields, 'name', 'title', and
- 'birth_date', the forms above will contain exactly the same fields.
+Since the Author model has only 3 fields, 'name', 'title', and
+'birth_date', the forms above will contain exactly the same fields.
.. note::