title: Django: Creating multiple class instances on a single webpage, with Foreign Key dependencies
body: <p>I have the following code in my <code>models.py</code>:</p>
  
  <pre><code>class Application(models.Model):
      team_name = models.CharField(max_length=100)
      ...
  
  class Participant(models.Model):
      name  = models.CharField(max_length=100)
      grade = models.SmallIntegerField(choices=GRADE_CHOICES, blank=True, null=True)
      application = models.ForeignKey(Application, related_name="participants")
      ...
  </code></pre>
  
  <p>i.e. There are multiple <code>Participants</code>, and each <code>Participant</code> will be on a single application. (It is defined that each <code>Application</code> will have exactly 8 <code>Participants</code>).</p>
  
  <p>The intended purpose of this code is that a user will be able to create a new application, on which he/she will name 8 <code>Participants</code>. When the <code>Application</code> is created, 8 new instances of <code>Participants</code> should also be created and linked such that each <code>Participant</code> has the newly created <code>Application</code> as its Foreign Key.</p>
  
  <p>I am currently struggling to create a form/view that will handle this creation process. I want the user to be a presented a single webpage that presents input forms that allow the user to create a new <code>Application</code> (name, etc.), along with 8 new <code>Participants</code> (each having a name, grade, etc.)</p>
  
  <p>My current <code>forms.py</code> has:</p>
  
  <pre><code>class ApplicationForm(forms.ModelForm):
      """
      A form that edits an application and all of its participants.
      """
  
      nationality = forms.CharField(disabled=True, required=False)
  
      class Meta:
          model = Application
          fields = '__all__'
  </code></pre>
  
  <p>But I realize that this does not display to the user what is needed to create 8 new <code>Participants</code> with the creation of this <code>Application</code>. How can I modify my <code>forms.py</code> to include space for the user to create 8 <code>Participants</code> with the creation of an <code>Application</code>?</p>
  
  <p>The only solution I can come up with is to manually list 8 <code>Participant</code> form calls in a single view, but I feel that there must be a better solution.</p>