是否可以使用django-polymorphic包并在父类中具有CharField并根据子类更改“选择”?
Ex)
class Shape(PolymorphicModel):
name = models.CharField(max_length=255)
status = models.CharField(max_length=255) # Will be modified per child class
CIRCLE_CHOICES = (("active", "Active"), ("ready","Ready To Go"), ("inactive","Deactive"))
class Circle(Shape):
status = models.CharField(max_length=255, choices=CIRCLE_CHOICES)
SQUARE_CHOICES = (("steady", "Steady"), ("inactive","Inactive"), ("ready","Ready"))
class Square(Shape):
status = models.CharField(max_length=255, choices=SQUARE_CHOICES)
我认为我可以覆盖父类中的原始状态,但是看起来我不能有重复的字段。
“类'Circle'中的本地字段'status'与基类'Shape'中具有相同名称的字段发生冲突。”
我还希望能够在管理页面上列出状态。