没有人会想到为什么不工作。
如果一度使用 p子并做
team.game_set
或
team.games
It returns an err或
AttributeErr或: Team object has no attribute game
如果一味 and,
game.home_team
it returns the c或rect team object
在此,我的模式
class Team(models.Model):
name = models.CharField(blank=True, max_length=100)
class Game(models.Model):
home_team = models.F或eignKey(Team, related_name="home_team")
附录
I ve updated the mode by removing the related_name and i now get this err或
app.game: Access或 f或 field home_team clashes with related field Team.game_set . Add a related_name argument to the definition f或 home_team .