Skip to content

Commit

Permalink
[1.5.x] Improvement on InlineFormSet doc, refs #21006
Browse files Browse the repository at this point in the history
Backport of 944a2bb from master
  • Loading branch information
Tianyi Wang authored and timgraham committed Oct 15, 2013
1 parent 1acd5fc commit 312ca5e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions docs/topics/forms/modelforms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ class's ``clean`` method::
class MyModelFormSet(BaseModelFormSet):
def clean(self):
super(MyModelFormSet, self).clean()
# example custom validation across forms in the formset:
# example custom validation across forms in the formset
for form in self.forms:
# your custom formset validation
...
Expand Down Expand Up @@ -917,14 +917,14 @@ When overriding methods on ``InlineFormSet``, you should subclass
:class:`~models.BaseInlineFormSet` rather than
:class:`~models.BaseModelFormSet`.

For example, If you want to override ``clean()``::
For example, if you want to override ``clean()``::

from django.forms.models import BaseInlineFormSet

class MyModelFormSet(BaseInlineFormSet):
class CustomInlineFormSet(BaseInlineFormSet):
def clean(self):
super(MyModelFormSet, self).clean()
# example custom validation across forms in the formset:
super(CustomInlineFormSet, self).clean()
# example custom validation across forms in the formset
for form in self.forms:
# your custom formset validation
...
Expand All @@ -935,7 +935,7 @@ Then when you create your inline formset, pass in the optional argument
``formset``::

>>> from django.forms.models import inlineformset_factory
>>> BookFormSet = inlineformset_factory(Author, Book, formset=MyModelFormSet)
>>> BookFormSet = inlineformset_factory(Author, Book, formset=CustomInlineFormSet)
>>> author = Author.objects.get(name=u'Mike Royko')
>>> formset = BookFormSet(instance=author)

Expand Down

0 comments on commit 312ca5e

Please sign in to comment.