【发布时间】:2019-08-06 06:29:34
【问题描述】:
我想在 django-oscar 的订单应用的 ShippingEventQuantity 模型中添加一个字段。但是这个模型不是抽象的,因此我正在努力寻找一种方法来覆盖它。
我尝试了以下尝试覆盖此模型。使用此代码,当我运行 makemigrations 命令时出现错误:
class SShippingEventQuantity(ShippingEventQuantity):
replacement = models.CharField(null=True, blank=True, max_length=255)
class Meta:
app_label = 'order'
verbose_name = _("Shipping Event Quantity")
verbose_name_plural = _("Shipping Event Quantities")
unique_together = ('event', 'line', 'replacement')
Errors:
order.SShippingEventQuantity: (models.E016) 'unique_together' refers to field 'event' which is not local to model 'SShippingEventQuantity'.
HINT: This issue may be caused by multi-table inheritance.
order.SShippingEventQuantity: (models.E016) 'unique_together' refers to field 'line' which is not local to model 'SShippingEventQuantity'.
HINT: This issue may be caused by multi-table inheritance.
我做错了什么?我能做些什么来解决这个问题?
【问题讨论】:
标签: django-models django-oscar