我可以这样吗(django填充manytomanyfield)

时间:2019-07-08 10:42:42

标签: django django-models

我为玩家team1playerteam2player有2个栏位,而且我有赢家和输家栏位,我想用team1player场或team2player来填充赢家和输家栏位字段

我可以用最短的方法吗?还是我应该再写一次这样的代码。 winner=models.ManyToManyField(Player,related_name='winner')

team1player=models.ManyToManyField(Player,related_name='team1player')
team2player=models.ManyToManyField(Player,related_name='team2player')
winner=models.ManyToManyField(select team1player or team2player)
loser=models.ManyToManyField(select team1player or team2player)

0 个答案:

没有答案