Wednesday, May 31, 2017

Re: ModelFormset Into InlineFormset



On Wed, May 31, 2017 at 3:13 PM, Matthew Pava <Matthew.Pava@iss.com> wrote:

I have a class CustomFormSet that inherits from BaseModelFormSet.  I would like to have another formset class that does everything CustomFormSet does but instead inherits from BaseInlineFormSet.  What is the best pythonic/Django way of doing that?

 


I would take the same approach that abstract model classes use. Collect the common functionality into a separate class, and mix the forms together with the desired inheritance hierarchy.

Since your inheritance hierarchy includes the Base*FormSet classes, your abstract form mixin can simply inherit from object to keep from adding unintended behavior. 

-James  

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciX9xDt3moEQPGdgy3SBt3xvPV3z3eUGun6eq%3DMSPKh_hQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment