我正在尝试在模型中使用多态表和非多态表之间的直通关系RankedAthlete
:
class ChoiceBlank(PolymorphicModel):
pass
class ChoiceAthlete(ChoiceBlank):
choice = models.ForeignKey('SomeModel', on_delete=models.CASCADE)
class BetMultiple(models.Model):
answer = models.ManyToManyField('ChoiceBlank', blank=True, through='RankedAthlete')
class RankedAthlete(models.Model):
choiceAthlete = models.ForeignKey('ChoiceBlank', on_delete=models.CASCADE)
bet = models.ForeignKey('BetMultiple', on_delete=models.CASCADE)
rank = models.IntegerField()
这不起作用,因为在我创建一个时RankedAthlete
期望 aChoiceBlank
和 a被提出。ValueError
相反,如果我将选项替换为ChoiceAthlete
.
Django-polymorphic文档没有提到我的用例,它不受支持吗?有没有办法使这项工作?