The list of all drivers in a team is (assuming self is a team instance)
drivers = self.driver_set().all() Hope that helps. Malcolm On Thu, Jan 21, 2010 at 2:49 AM, Ether Joe <ether....@gmail.com> wrote: > Hello there, quick (hopefully) question for you - how do I get a list > of records in a foreign table that point back to the object making the > query? > > For example - a Formula One racing team, where each Team has 0 or more > Drivers, and each Driver can be a member of only one Team. How do I > get a list of all Drivers that point to a specific Team, and then > display them on the Team page? Perhaps using a TeamAdmin or > TeamManager class? > > class Team(models.Model): > ... > class Driver(models.Model): > ... > team = models.ForeignKey(Team) > > I looked at using a TeamAdmin with an InlineModelAdmin pointing to > Driver. This gets me the Drivers on the Team page. But I don't want to > edit the Drivers - just display. Also, I want to do things with the > queryset (eg., count them). > > Thanks! > > > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.