马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 Curtain丶柒 于 2021-8-5 10:16 编辑
现在有两个基础类, 两个基础类都关联和同个外键, 分别用表A和B继承这两个基础类, 再用表B去关联A, 结果就报错了 , 我之前觉得应该不是有影响的, 现在不知道怎么解决才好, 难道要把基础类的每个字段在表AB都写一次吗(有很多类似表AB的都要继承这两个基础类)
各位大佬们帮帮我吧
代码:class BaseOperatorModel(models.Model):
"""为模型类补充操作/状态字段"""
operator = models.ForeignKey(to="jurisdiction.AdminInfo", null=True, verbose_name="操作人", related_name="operator_id")
operating_time = models.DateTimeField(null=True, verbose_name="操作时间")
remarks = models.TextField(null=True, verbose_name="备注")
status = models.SmallIntegerField(choices=((0, "禁用"), (1, "启用")), default=1, verbose_name="状态")
is_delete = models.SmallIntegerField(choices=((0, "否"), (1, "是")), default=0, verbose_name="是否删除")
class Meta:
abstract = True
class BaseReviewModel(models.Model):
"""为模型类补充审核字段"""
reviewer = models.ForeignKey(to="jurisdiction.AdminInfo", null=True, verbose_name="审核人", related_name="reviewer_id")
review_time = models.DateTimeField(null=True, verbose_name="审核时间")
review_remarks = models.DateTimeField(null=True, verbose_name="审核备注")
class Meta:
abstract = True
class SalesOrder(BaseModel, BaseOperatorModel, BaseReviewModel):
order_sn = models.CharField(max_length=100, unique=True, verbose_name="订单编号")
username = models.CharField(max_length=100, verbose_name="联系人")
class WarehouseOperatorOrder(BaseModel, BaseOperatorModel, BaseReviewModel):
order_sn = models.CharField(max_length=100, unique=True, verbose_name="订单编号")
production_order = models.ForeignKey(to="production.ProductionOrder", null=True, verbose_name="生产订单")
# 成品to销售订单
sales_order = models.ForeignKey(to="sales.SalesOrder", null=True, verbose_name="销售订单")
报错信息:HINT: Add or change a related_name argument to the definition for 'WarehouseOperatorOrder.reviewer' or 'SalesOrder.reviewer'.
那我蹭个最佳不过分吧
|