title: Django: custom constructor for form class, trouble with accessing data from request.POST
body: <p>I have written custom constructor for a form, the whole form class looks like this:</p>
  
  <pre><code>class UploadForm(forms.Form):
      file = forms.FileField(label = "Plik")
  
      def __init__(self, coto, naglowek, *args, **kwargs):
          super(UploadForm, self).__init__(*args, **kwargs)
          self.coto = coto
          self.naglowek = naglowek
  </code></pre>
  
  <p>When submitting form, in my view, I have something like</p>
  
  <pre><code>if request.method == 'POST':
      form = UploadForm(request.POST, request.FILES)
      if form.is_valid():
          add_form(request.FILES['file'])
          return HttpResponseRedirect('uploaded/')
  </code></pre>
  
  <p>The problem is, that when I am creating form in this way in my view, I am not passing <strong>coto</strong> and <strong>naglowek</strong>, so when I am calling <strong>form.is_valid()</strong> --> it returns false.</p>
  
  <p>The template which passess it looks like:</p>
  
  <pre><code>&lt;table class="uploadform"&gt;
  &lt;form action="." method="POST" enctype="multipart/form-data"&gt;
  {% for form in forms %} 
  &lt;tr&gt;
      &lt;td&gt;{{ form.naglowek }}&lt;/td&gt;
      &lt;td&gt;{{ form.file }}&lt;/td&gt;
      &lt;td&gt;&lt;input type="submit" name="{{ form.coto }}" id="{{ form.coto }}" value="Wyślij"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  {% endfor %}
  &lt;/form&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>I would be grateful for any suggestions.</p>
  
  <p><strong>[EDIT]</strong>
  I might not say this clearlly enough, but I will try my best:</p>
  
  <p>When I am submitting this form, in view, I need to know which submit button was pressed - I have many of them assigned to single form. From what I know, when I am assigning id to submit button, it should be availible in post, right? The trick is, that it is not availible. </p>
  
  <p>I have two questions:
   * What needs to be done, If I want to know which submit button was pressed? Is assigning the name the only way?
   * Is there any error in my logic?</p>