Form for multiple models <p>Suppose I have two models:</p> <pre><code>class Topic(models.Model): title = models.CharField() # other stuff class Post(models.Model): topic = models.ForeignKey(Topic) body = models.TextField() # other stuff </code></pre> <p>And I want to create a form contains two fields: <code>Topic.title</code> and <code>Post.body</code>. Of course, I can create the following form:</p> <pre><code>class TopicForm(Form): title = forms.CharField() body = forms.TextField() # and so on </code></pre> <p>But I don't want to duplicate code, since I already have <code>title</code> and <code>body</code> in models. I'm looking for something like this:</p> <pre><code>class TopicForm(MagicForm): class Meta: models = (Topic, Post) fields = { Topic: ('title', ), Post: ('body', ) } # and so on </code></pre> <p>Also, I want to use it in class based views. I mean, I would like to write view as:</p> <pre><code>class TopicCreate(CreateView): form_class = TopicForm # ... def form_valid(self, form): # some things before creating objects </code></pre> <p>As suggested in comments, I could use two forms. But I don't see any simple way to use two forms in my <code>TopicCreate</code> view - I should reimplement all methods belongs to getting form(at least).</p> <h2>So, my question is:</h2> <p>Is there something already implemented in Django for my requirements? Or is there a better(simpler) way?</p> <p><strong>or</strong></p> <p>Do you know a simple way with using two forms in class based view? If so, tell me, it could solve my issue too.</p>