Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 从其他模型字段中选择django模型字段限制_Python_Django_Django Models_Django Admin - Fatal编程技术网

Python 从其他模型字段中选择django模型字段限制

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 =

我在做一个足球应用程序,我有一个固定装置或游戏模型,这可以得到两支球队,它为比赛增加了时间和内容,但我也有FixturedCard和FixturedGoals,现在发生的是FixtureGoals和FixturedCard有3个字段,赛程的外键和一个进球的球队的外键,然后是另一个来显示哪个球员进球了

基本夹具类

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中的选择吗?或