错误记录:(fields.E304) Reverse accessor for '' clashes with reverse accessor for ''.

本文详细解析了在Django模型中使用ForeignKey时遇到的错误E304,即反向访问器冲突问题,并提供了修改related_name参数以区分不同外键反向访问的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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
07-31 10:23:38.923236 3282 5623 D LogicalDisplayExt: set displayInfo flag FLAG_ROTATES_WITH_CONTENT 07-31 10:23:38.923283 3282 5623 D LogicalDisplayMapperExtImpl: setMainDisplayUniqueId+ 07-31 10:23:38.923287 3282 5623 D LogicalDisplayMapperExtImpl: setMainDisplayUniqueId- 07-31 10:23:38.923337 3282 5623 I LogicalDisplayMapper: Applying layout: [{dispId: 0(ON), displayGroupName: , addr: {port=131, model=0x40446d8c8efefc}, mThermalBrightnessThrottlingMapId: null, mRefreshRateZoneId: null, mLeadDisplayId: -1, mLeadDisplayAddress: null, mThermalRefreshRateThrottlingMapId: null, mPowerThrottlingMapId: null}], Previous layout: [{dispId: 0(ON), displayGroupName: , addr: {port=131, model=0x40446d8c8efefc}, mThermalBrightnessThrottlingMapId: null, mRefreshRateZoneId: null, mLeadDisplayId: -1, mLeadDisplayAddress: null, mThermalRefreshRateThrottlingMapId: null, mPowerThrottlingMapId: null}] 07-31 10:23:38.923368 3282 5623 I LogicalDisplayMapper: Setting new display group 0 for display 4, from previous group: null 07-31 10:23:38.923407 3282 5623 D LogicalDisplayExt: set displayInfo flag FLAG_ROTATES_WITH_CONTENT 07-31 10:23:38.924356 3282 5623 W DisplayPowerController[display=4]: Screen brightness nits configuration is unavailable; falling back 07-31 10:23:38.924487 3282 5623 D BrightnessMappingStrategyExtImpl: create OplusMappingStrategy. 07-31 10:23:38.924588 3282 5623 D BrightnessMappingStrategyExtImpl: create OplusMappingStrategy. 07-31 10:23:38.924639 3282 5623 D BrightnessMappingStrategyExtImpl: create OplusMappingStrategy. 07-31 10:23:38.924701 3282 5623 D DisplayPowerController[display=4]: DPC construct virtual:com.oplus.olc,1000,olc_mediaProjection,1 mIsPrimaryDisplay:false 07-31 10:23:38.925032 3282 5623 D DisplayManagerServiceExtImpl: scheduleTraversalLocked intraversal=false 07-31 10:23:38.925087 3282 5623 I DisplayManagerServiceExtImpl: handle logical display changed logicalDisplay=id=4,stack=4,content=false,displayInfo{stack=4,type=5,id=4,uId=virtual:com.oplus.olc,1000,olc_mediaProjection,1,state=UNKNOWN,pkg=com.oplus.olc} 07-31 10:23:38.925213 3282 5623 V WindowManager: Content Recording: Handle incoming session on display 4, with a pre-existing session null 07-31 10:23:38.925255 3282 3387 D DisplayManagerService: Delivering display event: displayId=4, event=EVENT_DISPLAY_CONNECTED 07-31 10:23:38.925344 3282 3389 I SurfaceControl: setPosition: sc Surface(name=Surface(name=49c5b96 com.oplus.logkit/com.oplus.logkit.collect.activity.CollectActivity)/@0x801e304 - animation-leash of window_animation)/@0xca61534 tx=14096082684479 x=0.0 y=2433.6829 ,layerId= 1091 caller=SurfaceControl.java.setPosition:3624 SurfaceControl.java.setMatrix:3980 WindowAnimationSpec.java.apply:139 SurfaceAnimationRunner.java.applyTransformation:372 SurfaceAnimationRunner.java.lambda$startAnimationLocked$3:280 null.$r8$lambda$XKYbomSeJZ5X1QvoC6W5WshA39k:0 D8$$SyntheticClass.onAnimationUpdate:0 Animator.java.lambda$static$4:952 D8$$SyntheticClass.call:0 Animator.java.callOnList:763 07-31 10:23:38.925524 3282 5623 D WallpaperControllerExtImpl: handleWallpaperCreated: mLastWallPaperId = 3 高通定屏日志解释与分析
最新发布
08-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值