How to use create view on multiple models

Is it possible to insert multiple models on one class based create view? If so how does one go about it?

So there are a couple of different scenarios here, and the answers would vary based upon the precise behavior being looked for.

  1. Multiple separate models with multiple submit buttons - each submit button submitting their own form and the other forms are ignored.

  2. Multiple separate models that are related, and one submit button saves all.

  3. Multiple separate models that aren’t related, and one submit button saves all.

What I have done in the past for #2 is to use the formset facility with the formset having a limit of 1 form, and not providing any facility to add forms.


Hi i try to add > topic for spacific Board by CreateView But when i try it add i can’t pass pk for Board to add Topic for them
and i can’t send url from link to include pk for Board
how i can slove this

This looks like a different question on a different topic. Rather than adding to this thread, go ahead and create a new topic for this. When you do, please include more details. This may include posting your view and the models involved. When you do post code here, enclose it between lines consisting of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```. (The ``` must be lines on their own.)