Django 出现的错误

1、一张表多次引用某个外键

ERRORS:
Work_Dao.Apply.applicant: (fields.E304) Reverse accessor for 'Work_Dao.Apply.applicant' clashes with reverse accessor for 'Work_Dao.Apply.hander'.
        HINT: Add or change a related_name argument to the definition for 'Work_Dao.Apply.applicant' or 'Work_Dao.Apply.hander'.
Work_Dao.Apply.applicant: (fields.E305) Reverse query name for 'Work_Dao.Apply.applicant' clashes with reverse query name for 'Work_Dao.Apply.hander'.
        HINT: Add or change a related_name argument to the definition for 'Work_Dao.Apply.applicant' or 'Work_Dao.Apply.hander'.
Work_Dao.Apply.hander: (fields.E304) Reverse accessor for 'Work_Dao.Apply.hander' clashes with reverse accessor for 'Work_Dao.Apply.applicant'.
        HINT: Add or change a related_name argument to the definition for 'Work_Dao.Apply.hander' or 'Work_Dao.Apply.applicant'.
Work_Dao.Apply.hander: (fields.E305) Reverse query name for 'Work_Dao.Apply.hander' clashes with reverse query name for 'Work_Dao.Apply.applicant'.
        HINT: Add or change a related_name argument to the definition for 'Work_Dao.Apply.hander' or 'Work_Dao.Apply.applicant'.
Work_Dao.Task_list.Distributor: (fields.E304) Reverse accessor for 'Work_Dao.Task_list.Distributor' clashes with reverse accessor for 'Work_Dao.Task_list.people_work'.
        HINT: Add or change a related_name argument to the definition for 'Work_Dao.Task_list.Distributor' or 'Work_Dao.Task_list.people_work'.
Work_Dao.Task_list.people_work: (fields.E304) Reverse accessor for 'Work_Dao.Task_list.people_work' clashes with reverse accessor for 'Work_Dao.Task_list.Distributor'.
        HINT: Add or change a related_name argument to the definition for 'Work_Dao.Task_list.people_work' or 'Work_Dao.Task_list.Distributor'.

WARNINGS:
My_project.Sign.my_user: (fields.W342) Setting unique=True on a ForeignKey has the same effect as using a OneToOneField.
        HINT: ForeignKey(unique=True) is usually better served by a OneToOneField.
UserProfiles_app.UserProfile.user: (fields.W342) Setting unique=True on a ForeignKey has the same effect as using a OneToOneField.
        HINT: ForeignKey(unique=True) is usually better served by a OneToOneField.

原因:因为在一个表中多次引用某个外键表,而且没有指定唯一的related_name,而导致的。
解决方案:将同一个表中外键,增加不同的related_name。

2、DateTimeField 出现8小时误差

在这里插入图片描述
在setting.py中找到 USE_TZ 把True 改成 False 就ok了

3、django-allauth 改为邮箱登陆时正确的邮箱和密码也无法认证登陆

为使用户只能通过邮箱登陆,settings.py有如下配置:

ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_AUTHENTICATION_METHOD = 'email'  # 指定登陆
ACCOUNT_UNIQUE_EMAIL = True

但是在实际中发现,填写正确的邮箱和密码也提示“您提供的e-mail地址或密码不正确 django allauth”

最后的解决方法是在settings.py中添加:

AUTHENTICATION_BACKENDS = (
    # Needed to login by username in Django admin, regardless of `allauth`
    "django.contrib.auth.backends.ModelBackend",
    # `allauth` specific authentication methods, such as login by e-mail
    "allauth.account.auth_backends.AuthenticationBackend"
)

http://www.sarahhagstrom.com/2013/09/the-missing-django-allauth-tutorial/
是什么原理还有待挖掘

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值