Given a scenario like:
from django.db import models
class Player(models.Model):
playername = models.CharField()
class Team(models):
teamname = models.CharField()
class Members(models):
player = models.ForeignKey(Player)
team = models.ForeignKey(Team)
class Division(models):
divname = models.CharField()
class DivisionTeam(models):
division = models.ForeignKey(Division)
team = models.ForeignKey(Team)
How can I list all distinct players in division id = 5? I've look through the Q and F expressions, but I'm not looking for a complex set of or's. I am wondering if there is a way to chain a number of object1_set.object2_set.all()
type structures, or do I set up a nested loops to build the object (to be passed to template via context) with eventual {% for p in players %}
type loop in the template. The div id is passed through as a request variable.