私は、子の 1 つが別の子に依存しているポリモーフィック モデルを持っています。ただし、これにより、移行で予期しない問題が発生するようです。
以下に、これらのモデルの単純化されたバージョンを示します。
from django.db import models
from polymorphic.models import PolymorphicModel
class Poly(PolymorphicModel):
name = models.CharField(max_length=100)
class ChildA(Poly):
some_field = models.CharField(max_length=100)
class ChildB(Poly):
some_other_field = models.CharField(max_length=100)
childa = models.ForeignKey(ChildA, on_delete=models.CASCADE)
移行を実行すると、次のエラーが表示されます。poly.ChildB.childa: (models.E006) The field 'childa' clashes with the field 'childa' from model 'poly.poly'.
バニラの Django を使用すると、同じ動作に気付きました。
from django.db import models
class Poly(models.Model):
name = models.CharField(max_length=100)
class ChildA(Poly):
some_field = models.CharField(max_length=100)
class ChildB(Poly):
some_other_field = models.CharField(max_length=100)
childa = models.ForeignKey(ChildA, on_delete=models.CASCADE)
私は何を間違っていますか?