修改abstract_class的变量(models.model)

时间:2015-06-23 17:52:25

标签: python-2.7 django-models django-oscar

我想修改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)

...

0 个答案:

没有答案