title: Getting the first item item in a many-to-many relation in Django
body: <p>I have two models in Django linked together by ManyToMany relation like this:</p>
  
  <pre><code>class Person(models.Model):
      name = models.CharField(max_length=128)
  
  class Group(models.Model):
      name = models.CharField(max_length=128)
      members = models.ManyToManyField(Person)
  </code></pre>
  
  <p>I need to get the main person in the group which is the first person in the group. How can I get the first person?</p>
  
  <p>Here's how I'm adding members:</p>
  
  <pre><code>grp = Group.objects.create(name="Group 1")
  grp.save()
  prs = Person.objects.create(name="Tom")
  grp.members.add(prs) #This is the main person of the group.
  prs = Person.objects.create(name="Dick")
  grp.members.add(prs)
  prs = Person.objects.create(name="Harry")
  grp.members.add(prs)
  </code></pre>
  
  <p>I don't think I need any additional columns as the id of the table <code>group_members</code> is a running sequence right.</p>
  
  <p>If I try to fetch the main member of the group through <code>Group.objects.get(id=1).members[0]</code> then Django says that the manager is not indexable.</p>
  
  <p>If I try this <code>Group.objects.get(id=1).members.all().order_by('id')[0]</code>, I get the member with the lowest id in the <code>Person</code> table.</p>
  
  <p>How can I solve this?</p>
  
  <p>Thanks</p>