title: How to create form field for every foreign key in django?
body: <p>I am trying to build a form and I am not sure how this should be done correctly. These are my models:  </p>
  
  <pre><code>class Country(models.Model):
      name = models.CharField(max_length=250, null=False, blank=False, unique=True)
      twocode = models.CharField(max_length=5, null=False, blank=False, unique=True)
  
  class GeoBonus(models.Model):
      name = models.CharField(max_length=250)
      country = models.ForeignKey(Country, related_name='geo_bonuses')
      bookmaker = models.ForeignKey(Bookmaker, related_name='geo_bonuses')
  </code></pre>
  
  <p>Bookmaker has bonuses, different for each country. For example:</p>
  
  <pre><code>Bookmaker has bonuses:
      Slovakia: "eligible for 100% up to $200"
      Afghanistan: "eligible for 100% up to €100!"
      USA: "restricted country"
      ...
  </code></pre>
  
  <p>And I want to save text in quotes as <code>name</code> in GeoBonus. Of course I can write use simple model form, but I would have submit form 248 time(for each country). I would like to show all fields for each country. </p>
  
  <ul>
  <li>If <code>name</code> is blank, GeoBonus will not be created. </li>
  <li>If <code>name</code> is not blank, create GeoBonus object.
  This is what it should look like:
  <a href="https://i.stack.imgur.com/rbC2B.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rbC2B.png" alt="GeoBonus form bootstrap"></a>
  How code in <strong>forms.py</strong> and <strong>views.py</strong> will look like? I also need to <strong>edit</strong> fields.</li>
  </ul>
  
  <hr>
  
  <p>I tried to manually create new fields for countries:</p>
  
  <pre><code>&lt;form method="post" action="" class="wide"&gt;
          {% csrf_token %}
          {%bootstrap_form form %}
          &lt;div class="form-group"&gt;
          {%for country in countries%}
          &lt;label class="control-label" for="{{country.twocode}}"&gt;{{country}}&lt;/label&gt;
              &lt;input class="form-control" id="{{country.twocode}}" maxlength="250" type="text" /&gt;
          {%endfor%}
          &lt;/div&gt;
          &lt;input type="submit"  class="btn btn-default" name="submit" value="Save"&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>Using this forms.py class:</p>
  
  <pre><code>class GeoBonusForm(forms.ModelForm):
      class Meta:
          model = GeoBonus
          fields = ['bookmaker']
  </code></pre>
  
  <p>But <code>request.POST</code> does contain only bookmaker field.</p>
  
  <p>EDIT1: Views.py</p>
  
  <pre><code>@staff_member_required
  def geo_bonus_edit(request, bookmaker=None):
      template = loader.get_template('geobonus/edit.html')
      if request.method == 'POST':
          form = GeoBonusForm(request.POST)
          print request.POST
      else:
          form = GeoBonusForm()
      context = RequestContext(request, {
          'form': GeoBonusForm,
          'countries': Country.objects.all(),
      })
      return HttpResponse(template.render(context))
  </code></pre>