title: Getting and displaying related objects in Django
body: <p>I know this is simple, but I can't get my head around how to join some models together to display in my template in Django. I have "groups" that can have several "contacts".</p>
  
  <p>So far I've got:</p>
  
  <pre><code>class Group(models.Model):
      group_name = models.CharField()
  
  class Contact(models.Model):
      contact_name = models.ForeignKey(Group)
  </code></pre>
  
  <p>In my view, at first I assumed that simply getting my groups would also get any attached contacts, however that doesn't appear to be happening as expected:</p>
  
  <pre><code>def get_queryset(self):
      groups = Group.objects.all()
      return groups
  </code></pre>
  
  <p>I was expecting to do something like this in my template:</p>
  
  <pre><code>{% for group in groups %}
      &lt;h2&gt;{{ group.group_name }}&lt;/h2&gt;
      {% for c in group.contact %}
          &lt;h3&gt;{{ c.contact_name }}&lt;/h3&gt;
      {% endfor %}
  {% endfor %}
  </code></pre>
  
  <p>This isn't working - what am I doing wrong?  What is the correct query in my view to make sure the contact(s) for each group is getting retrieved?</p>