title: django model form, restrict choices based on value in ForeignKey model
body: <p>I have two models: <code>League</code> and <code>Team</code>. <code>Team</code> has a foreign key link to <code>League</code>. I want to be able to set choices available for the <code>Team</code> based on values stored in <code>League</code>. Specifically:</p>
  
  <pre><code>class League(models.Model):
      number_of_teams = models.IntegerField()
  
  class Team(models.Model):
      league = models.ForeignKey(League)
      draft_slot = models.IntegerField(choices=[(i+1,i+1) for i in range(?????????)])
  </code></pre>
  
  <p>I recognize I cannot accurately define my <code>draft_slot.choices</code> in the <code>Team</code> model. So I would expect to set up <code>Team</code> like so:</p>
  
  <pre><code>class Team(models.Model):
      league = models.ForeignKey(League)
      draft_slot = models.IntegerField()
  </code></pre>
  
  <p>I have set up a <code>ModelForm</code> of <code>Team</code>:</p>
  
  <pre><code>class TeamModelForm(ModelForm):
      class Meta:
          model = Team
  </code></pre>
  
  <p>And a view of the <code>Team</code> <code>ModelForm</code>:</p>
  
  <pre><code>def SetupTeam(request, fanatic_slug=None, league_slug=None):
      league = League.objects.get(slug=league_slug)
      form = TeamModelForm()
      return render_to_response('league/addteam.html', {
          'form': form
      }, context_instance = RequestContext(request))
  </code></pre>
  
  <p>What foo do I need in order to use <code>league.id</code>, <code>league.number_of_teams</code> so the view of <code>TeamModelForm</code> prepopulates <code>team.league</code> and also renders a field to represent <code>team.draft_slot</code> to look like</p>
  
  <pre><code>draft_slot = models.IntegerField(choices=[(i+1,i+1) for i in range(league.number_of_teams+1)])
  </code></pre>