Django multiple generic_inline_formset in a view
Posted
by Can Burak Cilingir
on Stack Overflow
See other posts from Stack Overflow
or by Can Burak Cilingir
Published on 2010-04-21T04:37:49Z
Indexed on
2010/04/21
4:43 UTC
Read the original article
Hit count: 300
We have a bunch of formsets:
EmailAddressInlineFormSet = generic_inlineformset_factory(
EmailAddress, extra=1,
exclude=["created_by","last_modified_by"])
emailaddressformset = EmailAddressInlineFormSet(
instance=person,
prefix="emailaddress")
# [ more definitions ]
and, in the view, we process them as:
emailaddressformset = EmailAddressInlineFormSet(
request.POST,
instance=person,
prefix="emailaddress")
# [ more definitions ]
So, nothing fancy or unordinary.
The unfortunate or unordinary fact is, we have 15 of these formsets, one for email addresses, other for phone numbers etc. so the view code is ugly and not-so-manageable. What would be the most unhackish way to handle this number of formsets in a single view?
At the end -i guess- I'm looking for a class or a functionality like multiple_generic_inline_formset
and open to all kind of suggestions or discussions.
© Stack Overflow or respective owner