title: Table join using the Django ORM
body: <p>I'm trying to figure out the Django ORM and I'm getting a little confused on the equivalent of a table join.</p>
  
  <p>Assume I have the three models below, abbreviated for readability. "User" is the out-of-the-box Django user model, "AppUser" is a corresponding model for storing additional profile info like zip code, and "Group" is a collection of users (note that this group has nothing to do with authentication groups). Each AppUser has a one-to-one relationship with each User. Similarly, each AppUser also points to the Group of which that user is member (which could be None). </p>
  
  <p>My task: given a group_id, generate a list of all the member emails. </p>
  
  <p>I know that I can "traverse backward one-level" from Group to AppUser using <code>.appuser_set.all()</code> but I don't know how to go further to fetch the related User and its email without iterating through and doing it in a very DB heavy way like this:</p>
  
  <pre><code>appUser = AppUser.objects.get(user_id=request.user.id)
  group = appUser.group
  appUsers = group.appuser_set.all()
  emails = []
  for x in appUsers:
      emails.append(x.user.email) 
  </code></pre>
  
  <p>Alternatively I could write a raw SQL join to do it but suspect the Django ORM is capable. 
  What's the proper and most efficient way to do this? </p>
  
  <p>Models:</p>
  
  <pre><code>class User(Model):
      id = IntegerField()
      username = CharField()
      email = CharField()
  
      class Meta:
          db_table = "auth_user"
  
  
  class AppUser(Model):
      user = OneToOneField(User, primary_key=True)
      group = ForeignKey('Group', null=True, on_delete=SET_NULL)
      zip = CharField()
  
      class Meta:
          db_table = "app_users"
  
  
  class Group(Model):                
      creator = ForeignKey(AppUser, related_name='+')
      created = DateTimeField()
      name = CharField()
  
      class Meta:
          db_table = "groups"
  </code></pre>