我想修改STRUCTURE_CHOICES,以便它可以反映到结构字段选择中。
类AbstractProduct(models.Model):
...
STRUCTURE_CHOICES = (
(STANDALONE, _('Stand-alone product')),
(PARENT, _('Parent product')),
(CHILD, _('Child product'))
)
...
structure = models.CharField(
_("Product structure"), max_length=10, choices=STRUCTURE_CHOICES,
default=STANDALONE)
...
类产品(AbstractProduct):
...
STRUCTURE_CHOICES = (
(STANDALONE, _('Stand-alone product')),
(PARENT, _('Parent product')),
(CHILD, _('Child product')),
(NEW_CHOICE, _('New Choice'))
)
...
我尝试过这样做,但它没有用:
类产品(AbstractProduct): ...
def __init__(self, *args, **kwargs):
self.STRUCTURE_CHOICES = (
(STANDALONE, _('Stand-alone product')),
(PARENT, _('Parent product')),
(CHILD, _('Child product')),
(NEW_CHOICE, _('New Choice'))
)
return super(Product, self).__init__(*args, **kwargs)
...