Skip to content Skip to sidebar Skip to footer

Pendant To Inline Formsets For Many-to-many Relations

Following Kevin Dias instructions in this article, I try to generate one form for two related models. This seems to work for one-to-many relations, however I run into problems usin

Solution 1:

As you're probably aware, you can't edit many-to-many relationships with inline formsets. You can, however, edit the through model. So for your inline formset, you just need to set the model to the through model, like so:

RoleFormSet = inlineformset_factory(UserRole, User.role.through)

Post a Comment for "Pendant To Inline Formsets For Many-to-many Relations"