[Answer]-Django – Limit User Queries

1👍

player.team.player_set.all()

if a every user is a player:

class Player(models.Model):
    user = models.OneToOne(User)
    first_name = ...
    last_name = ...
    # Assign players to a team.
    team = models.ForeignKey(Team)
    # Whatever stats you want to keep on the players

and in your view:

request.user.player.team.player_set.all()

Leave a comment