[Fixed]-Django formset – how to update an object?


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

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

Leave a comment