title: Using field values from a ForeignKeyed object for ModelChoiceFields
body: <p>My friends and I play a spreadsheet-based sports picking game which is very tedious to make changes to. I've wanted to learn Django for a while so I've been working on creating it as a webapp. Here are the models I'm working with:</p>
  
  <pre><code>class Sheet(models.Model):
  user = models.ForeignKey(User)
  ... other stuff
  
  class Game(models.Model):
  home_team = models.CharField(max_length=100, default='---')
  away_team = models.CharField(max_length=100, default='---')
  ... other stuff
  
  class Pick(models.Model):
  sheet = models.ForeignKey(Sheet)
  game = models.ForeignKey(Game)
  HOME = 'H'
  AWAY = 'A'
  PICK_TEAM_CHOICES = (
      (HOME, 'Home'),
      (AWAY, 'Away'),
  )
  pick_team = models.CharField(max_length=4,
                                    choices=PICK_TEAM_CHOICES,
                                    default=HOME)
  ... other stuff
  </code></pre>
  
  <p>Right now, I'm trying to nail down a simple way to display the following form with information from a foreign keyed model instead of the <code>pick_team</code> default choices. The <code>game</code> is hidden because it's paired with the generated PickForm via use of the <code>initial</code> functionality in the view.</p>
  
  <pre><code>class PickForm(ModelForm):
    class Meta:
        model = Pick
        widgets = {'game': forms.HiddenInput()}
        fields = ['sheet','game','amount','pick_type','pick_team']
  
    def __init__(self, *args, **kwargs):
        game = kwargs['initial']['game']
        super(PickForm, self).__init__(*args, **kwargs)
        self.fields['pick_team']=forms.ModelChoiceField([game.away_team,game.home_team])
  </code></pre>
  
  <p>From what I can tell, the ModelChoiceField expects a queryset- so when I provide a list or a tuple, I get a <code>'list' object has no attribute 'iterator'</code> error. Knowing this now, how can I display the Game fields <code>home_team</code> and <code>away_team</code> in the pick_team dropdown on the template? Currently it defaults to 'Home' and 'Away'.</p>
  
  <p>I know this is a common question at the core- how to display ForeignKeyed information in a dropdown, however all the answers I've found are fine with providing a queryset to ModelChoiceField, because they're typically trying to list a field from every object (or some filtered subset). In this case, I only want to list 2 fields, and only from one object.</p>
  
  <p>I tried returning a queryset consisting of the Game object already present in kwargs, but it just displays the game's <strong>str</strong>() method in the dropdown, and attempting to refine the queryset with the relevant field names isn't working either.</p>
  
  <p>EDIT: I realized that actually using the <code>home_team</code> and <code>away_team</code> values from the <code>Game</code> object would require extra processing on saving the <code>Pick</code>, or possibly be harder than that. Is there any way to do this sort of aliasing in the template alone? Similar to how with choice fields I can use <code>get_pick_team_display</code> to show a nicer looking display value ('Home', 'Away') instead of the vague 'H' or 'A'.</p>
  
  <p>EDIT2: View code
      class GameDetail(DetailView):
      #model = Game
      template_name = 'app/games.html'
      context_object_name = 'game_detail'</p>
  
  <pre><code>def get_object(self):
      game = get_object_or_404(...object filtering)
      return game
  
  def get_context_data(self, **kwargs):
      context = super().get_context_data(**kwargs)
      try:
          pick = Pick.objects.get(game=context['game_detail'],
       ....other stuff)
  
          context['pickform'] = PickForm(initial={'game':context['game_detail'],
       .... other stuff
      except Pick.DoesNotExist:
          #pick = none
          context['pickform'] = PickForm(initial={'game':context['game_detail'],
                                              })
  
      return context
  
  def post(self, request, *args, **kwargs):
      form = PickForm(request.POST)
      if form.is_valid():
          ....process form
  </code></pre>