#21006: Add an example of the formset argument for inlineformset_factory
--------------------------------------+------------------------------------
     Reporter:  treysta@…             |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  Documentation         |                  Version:  1.5
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------
Changes (by timo):

 * needs_better_patch:   => 0
 * needs_tests:   => 0
 * needs_docs:   => 0
 * type:  Uncategorized => Cleanup/optimization
 * stage:  Unreviewed => Accepted


Old description:

> https://docs.djangoproject.com/en/1.5/topics/forms/modelforms
> /#overriding-clean-on-an-inlineformset
>
> It looks like there is a somewhat relevant piece of information missing
> from this section. It leaves out the fact that you also must specify
> which formset to use when creating your inlineformset in the view:
>
> Currently:
>
> "See Overriding clean() on a ModelFormSet, but subclass BaseInlineFormSet
> rather than BaseModelFormSet."
>
> Suggestion:
>
> "See Overriding clean() on a ModelFormSet, but subclass BaseInlineFormSet
> rather than BaseModelFormSet. You must also specify which formset to use
> when creating your inlineformset in your view:"
>
> >>> from django.forms.models import inlineformset_factory
> >>> BookFormSet = inlineformset_factory(Author, Book''', formset=
> MyInlineFormSet''')
> >>> author = Author.objects.get(name=u'Mike Royko')
> >>> formset = BookFormSet(instance=author)

New description:

 https://docs.djangoproject.com/en/1.5/topics/forms/modelforms/#overriding-
 clean-on-an-inlineformset

 It looks like there is a somewhat relevant piece of information missing
 from this section. It leaves out the fact that you also must specify which
 formset to use when creating your inlineformset in the view:

 Currently:

 "See Overriding clean() on a ModelFormSet, but subclass BaseInlineFormSet
 rather than BaseModelFormSet."

 Suggestion:

 "See Overriding clean() on a ModelFormSet, but subclass BaseInlineFormSet
 rather than BaseModelFormSet. You must also specify which formset to use
 when creating your inlineformset in your view:"
 {{{
 >>> from django.forms.models import inlineformset_factory
 >>> BookFormSet = inlineformset_factory(Author, Book, formset=
 MyInlineFormSet)
 >>> author = Author.objects.get(name=u'Mike Royko')
 >>> formset = BookFormSet(instance=author)
 }}}

--

Comment:

 There's an example for `modelformset_factory` that uses the `formset`
 argument and while you might be able to infer a similar technique will
 work for `inlineformset_factory` since the docs say "Inline formsets is a
 small abstraction layer on top of model formsets", I agree an example
 could be helpful. I'm not sure it should be specific to the "Overriding
 clean()" section though, since the `formset` argument is useful for other
 cases as well.

 If you could offer a patch, I'll be happy to review and commit it. Thanks!

-- 
Ticket URL: <https://code.djangoproject.com/ticket/21006#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/075.0ac8a6c6980fca4ddb49f320d6ba16bc%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to