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/
是什么原理还有待挖掘