(错误记录:(fields.E304) Reverse accessor for '' clashes with reverse accessor for ''.)
ERRORS:
buy.Orders.buser: (fields.E304) Reverse accessor for ‘Orders.buser’ clashes with reverse accessor for ‘Orders.suser’.
HINT: Add or change a related_name argument to the definition for ‘Orders.buser’ or ‘Orders.suser’.
buy.Orders.suser: (fields.E304) Reverse accessor for ‘Orders.suser’ clashes with reverse accessor for ‘Orders.buser’.
HINT: Add or change a related_name argument to the definition for ‘Orders.suser’ or ‘Orders.buser’.
两个属性都关联一个外键 应该加一个related_name
class Orders(models.Model):
# 两个属性都关联一个外键 应该加一个related_name
buser = models.ForeignKey(UserInfo, verbose_name='买家',related_name='buser')
suser = models.ForeignKey(UserInfo, verbose_name='卖家',related_name='suser')
price = models.DecimalField(verbose_name='价格', max_digits=8, decimal_places=2)
ordertime = models.DateField(verbose_name='成交时间', auto_now_add=True)
car = models.OneToOneField(CarInfo, verbose_name='车辆信息')
# mileage = models.IntegerField(verbose_name='公里数')
orderStatus = models.IntegerField(verbose_name='订单状态', choices=ORDER_CHOICES, default=0)
isDelete = models.BooleanField(verbose_name='是否删除', default=False)
def __str__(self):
return self.buser.username
class Meta:
verbose_name = '交易记录表'
verbose_name_plural = verbose_name
网友评论