Skip to content

Commit

Permalink
[1.0.X] Fixed #11138 -- Corrected the description of behavior related…
Browse files Browse the repository at this point in the history
… to the max_num parameter for model formsets.

r10819 from trunk.


git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10820 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
kmtracey committed May 18, 2009
1 parent efbe48c commit ad2efbd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions docs/topics/forms/modelforms.txt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ Limiting the number of editable objects


As with regular formsets, you can use the ``max_num`` parameter to As with regular formsets, you can use the ``max_num`` parameter to
``modelformset_factory`` to limit the number of forms displayed. With ``modelformset_factory`` to limit the number of forms displayed. With
model formsets, this properly limits the query to select only the maximum model formsets, this property limits the query to select only the maximum
number of objects needed:: number of objects needed::


>>> Author.objects.order_by('name') >>> Author.objects.order_by('name')
Expand All @@ -531,10 +531,11 @@ number of objects needed::
>>> formset.initial >>> formset.initial
[{'id': 1, 'name': u'Charles Baudelaire'}, {'id': 3, 'name': u'Paul Verlaine'}] [{'id': 1, 'name': u'Charles Baudelaire'}, {'id': 3, 'name': u'Paul Verlaine'}]


If the value of ``max_num`` is less than the total objects returned, the If the value of ``max_num`` is higher than the number of objects returned, up to
formset will fill the rest with extra forms:: ``extra`` additional blank forms will be added to the formset, so long as the
total number of forms does not exceed ``max_num``::


>>> AuthorFormSet = modelformset_factory(Author, max_num=4, extra=1) >>> AuthorFormSet = modelformset_factory(Author, max_num=4, extra=2)
>>> formset = AuthorFormSet(queryset=Author.objects.order_by('name')) >>> formset = AuthorFormSet(queryset=Author.objects.order_by('name'))
>>> for form in formset.forms: >>> for form in formset.forms:
... print form.as_table() ... print form.as_table()
Expand Down

0 comments on commit ad2efbd

Please sign in to comment.