Say I am using an intermediary model like that in the doc: class Person(models.Model): name = models.CharField(max_length=128)
class Group(models.Model): name = models.CharField(max_length=128) members = models.ManyToManyField(Person, through='Membership') class Membership(models.Model): person = models.ForeignKey(Person) group = models.ForeignKey(Group) date_joined = models.DateField() For a given group, say I want to go through the persons in the group and print the date each joined the group. beatles = Group.objects.get(name="beatles") for person in group.members.all(): # get join date for person What's the best way to do this? It seems to me that I have to add a related_name to the person field of Membership like this: person = models.ForeignKey(Person, related_name="memberships") and then traverse backward from the person back to the membership, filtering to find the correct membership based on the group name. Can someone tell me if there is a better way? So I'm thinking I have to do this: beatles = Group.objects.get(name="beatles") for person in group.members.all(): joinDate = person.memberships.filter(group_name="beatles") [0].date_joined Thanks for any pointers, Margie -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.