[ACCEPTED]-Django formset - how to update an object?-django-forms

Accepted answer
Score: 17

Rather than use modelformset_factory, use inlineformset_factory - see the documentation here - sorry, should 7 have pointed you to that initially.

Then 6 you can drop the queryset stuff, since inlineformset_factory 5 takes care of that, and just pass the instance argument 4 (which here refers to the parent model, ie the Contact object). You 3 also won't need to iterate through explicitly 2 setting the contact attribute on save, as 1 again that's taken care of.

More Related questions