Python 从其他模型字段中选择django模型字段限制
我在做一个足球应用程序,我有一个固定装置或游戏模型,这可以得到两支球队,它为比赛增加了时间和内容,但我也有FixturedCard和FixturedGoals,现在发生的是FixtureGoals和FixturedCard有3个字段,赛程的外键和一个进球的球队的外键,然后是另一个来显示哪个球员进球了 基本夹具类Python 从其他模型字段中选择django模型字段限制,python,django,django-models,django-admin,Python,Django,Django Models,Django Admin,我在做一个足球应用程序,我有一个固定装置或游戏模型,这可以得到两支球队,它为比赛增加了时间和内容,但我也有FixturedCard和FixturedGoals,现在发生的是FixtureGoals和FixturedCard有3个字段,赛程的外键和一个进球的球队的外键,然后是另一个来显示哪个球员进球了 基本夹具类 class Fixture(TitleAndSlugModel): """ A division match fixture """ division =
class Fixture(TitleAndSlugModel):
"""
A division match fixture
"""
division = models.ForeignKey(Division)
fixture_date_time = models.DateTimeField()
team_a = models.ForeignKey("team.Team", related_name="team_a")
team_b = models.ForeignKey("team.Team", related_name="team_b")
固定目标
class FixtureGoal(BaseModel):
"""
A goal recorded against a match fixture
"""
fixture = models.ForeignKey(Fixture)
team = models.ForeignKey("team.Team")
player = ChainedForeignKey(
"team.TeamPlayer",
chained_field="team",
chained_model_field="team",
show_all=False,
auto_choose=True,
blank=True, null=True)
class Meta:
ordering = ["fixture", "team",]
def __unicode__(self):
return u'%s (%s)' % (self.fixture, self.player)
固定卡片
class FixtureRedCard(BaseModel):
"""
A red card recorded against a match fixture
"""
fixture = models.ForeignKey(Fixture)
team = models.ForeignKey("team.Team")
player = ChainedForeignKey(
"team.TeamPlayer",
chained_field="team",
chained_model_field="team",
show_all=False,
auto_choose=True,
blank=True, null=True)
class Meta:
ordering = ["fixture", "team",]
def __unicode__(self):
return u'%s (%s)' % (self.fixture, self.player)
我想做的是将选择限制在Fixture上选择的团队a和团队b,对于fixtureredcard和fixturegoal类中的现场团队,我如何实现这一点
谢谢您请查看此示例。您指的是在admin中限制ModelForm中的选择吗?或