title: Django multiple forms one Submit
body: <p>I know this question has been answered before on this site, but for the life of me I can't figure it out. I want to submit two forms at once, with <em>one</em> submit button. Please, can anybody identify what is wrong with my code, this is driving me insane.</p>
  
  <p><strong><code>HTML template</code> (edited)</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  
  
  &lt;form action="{% url "list" %}" method="post" enctype="multipart/form-data"&gt;
  
                  {% csrf_token %}
                  &lt;p&gt;{{ form.non_field_errors }}&lt;/p&gt;
  
                  &lt;p&gt;{{ form.docfile.label_tag }} {{ form.docfile.help_text }}&lt;/p&gt;
  
                  &lt;p&gt;
                      {{ form.docfile.errors }}
                      {{ form.docfile }}
                  &lt;/p&gt;
  
  
                  &lt;p&gt;{{ form.non_field_errors }}&lt;/p&gt;
  
                  &lt;p&gt;{{ form.docfile.label_tag }} {{ form.docfile.help_text }}&lt;/p&gt;
  
                  &lt;p&gt;
                      {{ form.docfile.errors }}
                      {{ form.docfile }}
                  &lt;/p&gt;
  
                  &lt;p&gt;&lt;input type="submit" value="Upload"/&gt;&lt;/p&gt;
              &lt;/form&gt;   
  
              &lt;!-- check error
              {% if form.errors %}
              {% for field in form %}
              {% for error in field.errors %}
              &lt;div class="alert alert-error"&gt;
                  &lt;strong&gt;{{ error|escape }}&lt;/strong&gt;
              &lt;/div&gt;
              {% endfor %}
              {% endfor %}
              {% for error in form.non_field_errors %}
              &lt;div class="alert alert-error"&gt;
                  &lt;strong&gt;{{ error|escape }}&lt;/strong&gt;
              &lt;/div&gt;
              {% endfor %}
              {% endif %} --&gt;
  
          &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong><code>views.py</code></strong></p>
  
  <pre><code># -*- coding: utf-8 -*-
  from django.shortcuts import render_to_response
  from django.template import RequestContext
  from django.http import HttpResponseRedirect
  from django.core.urlresolvers import reverse
  
  from myproject.myapp.models import Document
  from myproject.myapp.forms import DocumentForm
  from myproject.myapp.forms import DocumentForm2
  
  
  def list(request):
      # Handle file upload
      if request.method == 'POST':
          form = DocumentForm(request.POST, prefix="form")
          form2 = DocumentForm2(request.POST, prefix="form2")
  
          if form.is_valid() or form2.is_valid(): 
              newdoc = Document(docfile=request.FILES['docfile'])
              newdoc.save()
  
              # Redirect to the document list after POST
              return HttpResponseRedirect(reverse('myproject.myapp.views.list'))
      else:
          form = DocumentForm(prefix="form")  # A empty, unbound form
          form2 = DocumentForm2(prefix="form2")  # A empty, unbound form
  
      # Load documents for the list page
      documents = Document.objects.all()
  
      # Render list page with the documents and the form
      return render_to_response(
          'list.html',
          {'documents': documents, 'form': form},
          context_instance=RequestContext(request)
      )
  </code></pre>
  
  <p><strong><code>forms.py</code></strong></p>
  
  <pre><code># -*- coding: utf-8 -*-
  
  from django import forms
  
  
  class DocumentForm(forms.Form):
      docfile = forms.FileField(
          label='Select a file'
          )
  
  class DocumentForm2(forms.Form):
      docfile2 = forms.FileField(
          label='Select a file'
          )
  </code></pre>