title: How would I do these multiple joins as a Django queryset?
body: <p>I have this query that joins multiple tables together:</p>
  
  <pre><code>select 
      p.player_id
      , d.player_data_1
      , l.year
      , l.league
      , s.stat_1
      , l.stat_1_league_average
  from 
      stats s
  inner join players p on p.player_id = s.player_id
  left join player_data d on d.other_player_id = p.other_player_id
  left join league_averages as l on l.year = s.year and l.league = s.year
  where 
      p.player_id = 123
  </code></pre>
  
  <p>My models look like this:</p>
  
  <pre><code>class Stats(models.Model):
      player_id = models.ForeignKey(Player)
      stat_1 = models.IntegerField()
      year = models.IntegerField()
      league = models.IntegerField()
  
  
  class Player(models.Model):
      player_id = models.IntegerField(primary_key=True)
      other_player_id = models.ForeignKey(PlayerData)
  
  class PlayerData(models.Model):
      other_player_id = models.IntegerField(primary_key=True)
      player_data_1 = models.TextField()
  
  class LeagueAverages(models.Model):
      year = models.IntegerField()
      league = models.IntegerField()
      stat_1_league_average = models.DecimalField()
  </code></pre>
  
  <p>I can do something like this:</p>
  
  <pre><code>Stats.objects.filter(player_id=123).select_related('player')
  </code></pre>
  
  <p>to do the first join. For the second join, I tried: </p>
  
  <pre><code>Stats.objects.filter(player_id=123).select_related('player').select_related('player_data')
  </code></pre>
  
  <p>but I got this error:</p>
  
  <blockquote>
    <p>django.core.exceptions.FieldError: Invalid field name(s) given in select_related: 'player_data'. Choices are: player</p>
  </blockquote>
  
  <p>How would I do the third join considering that <code>year</code> and <code>league</code> aren't foreign keys in any of the tables? Thanks!</p>