title: Proper way to handle multiple forms on one page in Django
body: <p>I have a template page expecting two forms.  If I just use one form, things are fine as in this typical example:</p>
  
  <pre><code>if request.method == 'POST':
      form = AuthorForm(request.POST,)
      if form.is_valid():
          form.save()
          # do something.
  else:
      form = AuthorForm()
  </code></pre>
  
  <p>If I want to work with multiple forms however, how do I let the view know that I'm submitting only one of the forms and not the other (i.e. it's still request.POST but I only want to process the form for which the submit happened)?</p>
  
  <hr>
  
  <p><strong>This is the solution</strong> based on the answer where <em>expectedphrase</em> and <em>bannedphrase</em> are the names of the submit buttons for the different forms and <em>expectedphraseform</em> and <em>bannedphraseform</em> are the forms.</p>
  
  <pre><code>if request.method == 'POST':
      if 'bannedphrase' in request.POST:
          bannedphraseform = BannedPhraseForm(request.POST, prefix='banned')
          if bannedphraseform.is_valid():
              bannedphraseform.save()
          expectedphraseform = ExpectedPhraseForm(prefix='expected')
      elif 'expectedphrase' in request.POST:
          expectedphraseform = ExpectedPhraseForm(request.POST, prefix='expected')
          if expectedphraseform.is_valid():
              expectedphraseform.save() 
          bannedphraseform = BannedPhraseForm(prefix='banned')
  else:
      bannedphraseform = BannedPhraseForm(prefix='banned')
      expectedphraseform = ExpectedPhraseForm(prefix='expected')
  </code></pre>