是否可以使用 django-polymorphic 包并在父类中有一个 CharField 并根据子类更改“选择”?
前任)
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' 中的同名字段冲突。”
我还希望能够在管理页面上列出状态。