title: Accessing POST data in Django form
body: <p>I have been using <a href="http://jacobian.org/writing/dynamic-form-generation/" rel="noreferrer">this site</a> as an example of how to make a dynamic form in Django. In his view he uses</p>
  
  <pre><code>if request.method == 'POST':
      form = UserCreationForm(request.POST)
  </code></pre>
  
  <p>to pass the data into the form and in the form constructor he uses</p>
  
  <pre><code>extra = kwargs.pop('extra')
  </code></pre>
  
  <p>to access the POST data. I tried to do something similar with my view:</p>
  
  <pre><code>def custom_report(request):
      if request.method=='POST':
          form=CustomQueryConstraintForm(request.POST)
      else:
          form=CustomQueryConstraintForm()
      return render(request, 'frontend/custom_report.html', {'form':form})
  </code></pre>
  
  <p>In my form constructor I printed <code>args</code> and <code>kwargs</code> and found that <code>kwargs</code> is empty and <code>args</code> is a tuple containing the <code>QueryDict</code> that in turn contains the POST data. If I try instead to use <code>form=CustomQueryConstraintForm(**request.POST)</code>, each element in <code>kwargs</code> is a list containing the value of the field as its only element. Am I doing something wrong here? If not, is there a more elegant way of accessing the data than <code>args[0][element_name][0]</code>?</p>