[Django]-Creating Django Form from more than two models

3👍

You will need an inline formset per foreign key :

QuestionChoiceFormset = inlineformset_factory(question, choice)
QuestionAnswerFormset = inlineformset_factory(question, answer)

In your template, accessing for fields is just like for a normal formset / form.

@Rexford comment’s link is spot on, it does the same thing as what you want. You can find examples for functions based views as well based on the same ‘recipe’ example.

👤Val F.

Leave a comment