I'm starting to work on a small soccer league management website (mostly for learning purposes) and can't wrap my mind around a Django models relationship. For simplicity, let's say I have 2 types of objects - Player and Team. Naturally, a player belongs to one team so that's a ForeignKey(Team) in the Player model.
So I go:
class Team(models.Model):
name = models.CharField()
class Player(models.Model):
name = models.CharField()
team = models.ForeignKey(Team)
Then I want each team to have a captain which would be one of the players so that would be a ForeignKey(Player) in the Team model. But that would create a circular dependency.
Granted my Django experience is limited, but it seems like a simple problem, though I can't figure out what I'm doing wrong conceptually.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…