title: Django issues : Django ManagementForm data is missing or has been tampered with
body: <p>I have been going through every question ever asked in regards to this issue but can't seem to find the solution.</p>
  
  <p>I am trying to allow a user to submit multiple objects and save to the data base using a formset with 2 foreignkeys.</p>
  
  <p>I can get the Forms to save that data into the database but cannot get the forms in the formset to save because of the ManagementForm error. The issue is not that I don't have it in the HTML. (check the HMTL code below.) I also have a prefix set for the formset.</p>
  
  <p>I don't know if i need to create a custom form and formset instead of using model's. Maybe I need to Validate the information in formsets better.</p>
  
  <p>The error I get is:</p>
  
  <pre><code>/home/aking/signatureProject/signatureApp/views.py in signatures
          if formset.is_valid(): ...
  Variable    Value
  DD          &lt;DDForm bound=True, valid=True, fields=(downdraft_id)&gt;
  PR          &lt;PRForm bound=True, valid=True, fields=(report_id;report_desc)&gt;
  SignatureFormSet    &lt;class 'django.forms.formsets.SigFormFormSet'&gt;
  formset &lt;django.forms.formsets.SigFormFormSet object at 0x7f44601a4e10&gt;
  request &lt;WSGIRequest: POST '/signatureApp/signatures/'&gt;
  views.py
  
  /usr/lib64/python2.7/site-packages/django/forms/formsets.py in is_valid
  forms_valid True
  self    &lt;django.forms.formsets.SigFormFormSet object at 0x7f44601a4e10&gt;
  
  /usr/lib64/python2.7/site-packages/django/forms/formsets.py in errors
  self.full_clean() 
  self &lt;django.forms.formsets.SigFormFormSet object at 0x7f44601a4e10&gt;
  
  /usr/lib64/python2.7/site-packages/django/forms/formsets.py in full_clean
  for i in range(0, self.total_form_count()): 
  empty_forms_count  0
  self    &lt;django.forms.formsets.SigFormFormSet object at 0x7f44601a4e10&gt;
  
  /usr/lib64/python2.7/site-packages/django/forms/formsets.py in total_form_count
  return min(self.management_form.cleaned_data[TOTAL_FORM_COUNT], self.absolute_max) 
  self    &lt;django.forms.formsets.SigFormFormSet object at 0x7f44601a4e10&gt;
  
  /usr/lib64/python2.7/site-packages/django/utils/functional.py in __get__
  res = instance.__dict__[self.name] = self.func(instance) 
  cls &lt;class 'django.forms.formsets.SigFormFormSet'&gt;
  instance    &lt;django.forms.formsets.SigFormFormSet object at 0x7f44601a4e10&gt;
  self    &lt;django.utils.functional.cached_property object at 0x1b29dd0&gt;
  
  /usr/lib64/python2.7/site-packages/django/forms/formsets.py in management_form
   code='missing_management_form',
  form &lt;ManagementForm bound=True, valid=False, fields=(TOTAL_FORMS;INITIAL_FORMS;MIN_NUM_FORMS;MAX_NUM_FORMS)&gt;
  self &lt;django.forms.formsets.SigFormFormSet object at 0x7f44601a4e10&gt;
  </code></pre>
  
  <p>Views.py</p>
  
  <pre><code>from __future__ import unicode_literals
  from django.shortcuts import render
  from django.http import HttpResponse
  from signatureApp.forms import DDForm,PRForm,SigForm
  from django.forms.formsets import formset_factory
  
  def signatures(request):
      SignatureFormSet = formset_factory(SigForm)
      if request.method == "POST":
          DD = DDForm(request.POST)
          PR = PRForm(request.POST)
          formset = SignatureFormSet(request.POST, prefix='SFS')
          if DD.is_valid() and PR.is_valid():
              DD.save()
              PR.save(commit=False)
              PR.draft_id = DD.cleaned_data['draft_id']
              PR.save()
              if formset.is_valid():
                  for form in formset:
                      form.save(commit=False)
                      form.draft_id = DD.cleaned_data['draft_id']
                      form.report_id = PR.cleaned_data['report_id']
                      sig_type = form.cleaned_data.get('sig_type')
                      sig_desc = form.cleaned_data.get('sig_desc')
                      sig_rule = form.cleaned_data.get('sig_rule')
                      form.save(True)
      return render(request, 'reporting.html', {'DD':DDForm, 'PR':PRForm, 'SignatureFormSet':SignatureFormSet})
  </code></pre>
  
  <p>HTML</p>
  
  <pre><code>&lt;form class='signatures' method='POST'&gt;
      {% csrf_token %}
      {{ SignatureFormSet.management_form }}
          &lt;div id='draft'&gt;
              &lt;h1&gt;Enter Information from New Report Below&lt;/h1&gt;
              &lt;p&gt;&lt;strong&gt;ID:&lt;/strong&gt;&lt;br&gt;{{ DD.draft_id }}&lt;/p&gt;
          &lt;/div&gt;
          &lt;div id='report'&gt;
              &lt;p&gt;&lt;strong&gt;Report Number:&lt;/strong&gt;&lt;br&gt;{{ PR.report_id }}&lt;/p&gt;
              &lt;p&gt;&lt;strong&gt;Report Description:&lt;/strong&gt;&lt;br&gt;{{ PR.report_desc }}&lt;/p&gt;
          &lt;/div&gt;
          {% for form in SignatureFormSet %}
          &lt;div id='{{form.prefix}}' class='dynamic-form'&gt;
              &lt;p&gt;&lt;strong&gt;Signature Type:&lt;/strong&gt;&lt;br&gt;{{ form.sig_type }}&lt;/p&gt;
              &lt;p&gt;&lt;strong&gt;Signature Description:&lt;/strong&gt;&lt;br&gt;{{ form.sig_desc }}&lt;/p&gt;
              &lt;p&gt;&lt;strong&gt;Signature Rule:&lt;/strong&gt;&lt;br&gt;{{ form.sig_rule }}&lt;/p&gt;
          {% endfor %}
          &lt;/div&gt;
          &lt;div class="btn-group"&gt;
              &lt;button class="addSignature"&gt;Add a signature&lt;/button&gt;
              &lt;button id="submit-button"&gt;Submit&lt;/button&gt;
          &lt;/div&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>forms.py</p>
  
  <pre><code>from django import forms
  from signatureApp.models import draft_report, report, signatures
  
  class DDForm(forms.ModelForm):
      class Meta:
          model = draft_report
          fields = ['draft_id',]
  
  class PRForm(forms.ModelForm):
      class Meta:
          model = report
          exclude = ('draft_id',)
  
  class SigForm(forms.ModelForm):
      class Meta:
          model = signatures
          exclude = ('draft_id','report_id',)
  </code></pre>