title: Multiple text fields with id's in django
body: <p>I want to process multiple fields in django. In PHP I'm using generated HTML like:<br>
  </p>
  
  <pre><code>&lt;input type="text" name="myfield[1]" /&gt;
  &lt;input type="text" name="myfield[4]" /&gt;
  &lt;input type="text" name="myfield[5]" /&gt;
  </code></pre>
  
  <p>Where the number in brackets is id from db (cookies or other source).<br>
  When I process this form, I can get values from <code>$_POST['my field']</code> array by keys (1, 4, 5 in example).  </p>
  
  <p>I want to know, how can I do same thing in django and how to handle such multiple fields?
  I've created a list of checkboxes before. There I can store id in value of checkbox field, but it doesn't work with textfield, because in value I need value sent by user.  </p>
  
  <p>UPD:<br>
  I'm new with Django and Python (started Django just a few weeks ago).<br>
  models
  </p>
  
  <pre><code>from django.contrib.auth.models import User
  
  class Order(models.Model):
      category = models.ForeignKey(Category)
      exhibition = models.ForeignKey(Exhibition)
      user = models.ForeignKey(User)
      date = models.DateField()
      ordered = models.IntegerField()
  
  class Exhibition(models.Model):
      play = models.ForeignKey(Play)
      date = models.DateTimeField()
  
  class Category(models.Model):
      name = models.CharField(max_length=30)
      price = models.IntegerField()
      total = models.IntegerField()
  </code></pre>
  
  <p>view
  </p>
  
  <pre><code>from django.forms.models import modelformset_factory
  from tickets.forms import CourierForm
  
  def play_info_courier(request, pk):
      data = get_object_or_404(Exhibition, pk=pk)
      CourierFormSet = modelformset_factory(CourierForm, extra=0)
      orders = Order.objects.filter(exhibition=data).values()
      formset = CourierFormSet(initial=orders)
      context = RequestContext(request, {'data': data, 'formset': formset})
      return render_to_response('tickets/courier.html', context)
  </code></pre>
  
  <p>forms
  </p>
  
  <pre><code>class CourierForm(forms.ModelForm):
      class Meta:
          model = Order
  </code></pre>
  
  <p>html
  </p>
  
  <pre><code>&lt;form method="post" action=""&gt;
  {% csrf_token %}
  {{ formset.management_form }}
  &lt;table class="table table-bordered table-hover"&gt;
      {% for form in formset.forms %}
          {% if forloop.first %}
          &lt;thead&gt;
              &lt;tr&gt;
                  {% for field in form %}
                      {% if field.name != 'id' %}
                          &lt;th&gt;{{ field.label|capfirst }}&lt;/th&gt;
                      {% endif %}
                  {% endfor %}
              &lt;/tr&gt;
              &lt;/thead&gt;
          {% endif %}
              &lt;tr&gt;
                  &lt;!-- here is my problem, how can I get username from User
                  or anything else from other related models? --&gt;
                  &lt;td&gt;{{ form.user.username }}&lt;/td&gt;
                  &lt;td&gt;{{ form.category.price }}&lt;/td&gt;
                  &lt;td&gt;{{ form.date.value }}&lt;/td&gt;
                  &lt;td&gt;{{ form.ordered }}&lt;/td&gt;
              &lt;/tr&gt;
     {% endfor %}
  &lt;/table&gt;
  &lt;input type="submit" name="order" value="Order"/&gt;
  &lt;input type="submit" name="clean" value="Clean order"/&gt;
  &lt;/form&gt;
  </code></pre>