Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
  • Loading branch information...
commit 866d7fa961702353443edbaaeb253b823c77f6a7 1 parent 4271204
James Bennett authored

Showing 1 changed file with 24 additions and 24 deletions. Show diff stats Hide diff stats

  1. 48  docs/modelforms.txt
48  docs/modelforms.txt
@@ -226,7 +226,7 @@ For example::
226 226
 
227 227
     # Create a form instance with POST data.
228 228
     >>> a = Author()
229  
-    >>> f = AuthorForm(a, request.POST)
  229
+    >>> f = AuthorForm(request.POST, instance=a)
230 230
 
231 231
     # Create and save the new author instance. There's no need to do anything else.
232 232
     >>> new_author = f.save()
@@ -238,34 +238,34 @@ In some cases, you may not want all the model fields to appear on the generated
238 238
 form. There are three ways of telling ``ModelForm`` to use only a subset of the
239 239
 model fields:
240 240
 
241  
-    1. Set ``editable=False`` on the model field. As a result, *any* form
242  
-       created from the model via ``ModelForm`` will not include that
243  
-       field.
  241
+1. Set ``editable=False`` on the model field. As a result, *any* form
  242
+   created from the model via ``ModelForm`` will not include that
  243
+   field.
244 244
 
245  
-    2. Use the ``fields`` attribute of the ``ModelForm``'s inner ``Meta`` class.
246  
-       This attribute, if given, should be a list of field names to include in
247  
-       the form.
  245
+2. Use the ``fields`` attribute of the ``ModelForm``'s inner ``Meta``
  246
+   class.  This attribute, if given, should be a list of field names
  247
+   to include in the form.
248 248
 
249  
-    3. Use the ``exclude`` attribute of the ``ModelForm``'s inner ``Meta`` class.
250  
-       This attribute, if given, should be a list of field names to exclude
251  
-       the form.
  249
+3. Use the ``exclude`` attribute of the ``ModelForm``'s inner ``Meta``
  250
+   class.  This attribute, if given, should be a list of field names
  251
+   to exclude the form.
252 252
 
253  
-       For example, if you want a form for the ``Author`` model (defined above)
254  
-       that includes only the ``name`` and ``title`` fields, you would specify
255  
-       ``fields`` or  ``exclude`` like this::
  253
+For example, if you want a form for the ``Author`` model (defined
  254
+above) that includes only the ``name`` and ``title`` fields, you would
  255
+specify ``fields`` or ``exclude`` like this::
256 256
 
257  
-          class PartialAuthorForm(ModelForm):
258  
-              class Meta:
259  
-                  model = Author
260  
-                  fields = ('name', 'title')
261  
-
262  
-          class PartialAuthorForm(ModelForm):
263  
-              class Meta:
264  
-                  model = Author
265  
-                  exclude = ('birth_date',)
  257
+    class PartialAuthorForm(ModelForm):
  258
+        class Meta:
  259
+            model = Author
  260
+            fields = ('name', 'title')
  261
+    
  262
+    class PartialAuthorForm(ModelForm):
  263
+        class Meta:
  264
+            model = Author
  265
+            exclude = ('birth_date',)
266 266
 
267  
-        Since the Author model has only 3 fields, 'name', 'title', and
268  
-        'birth_date', the forms above will contain exactly the same fields.
  267
+Since the Author model has only 3 fields, 'name', 'title', and
  268
+'birth_date', the forms above will contain exactly the same fields.
269 269
 
270 270
 .. note::
271 271
 

0 notes on commit 866d7fa

Please sign in to comment.
Something went wrong with that request. Please try again.