一、问题
在Django中使用自定义的model的时候会出现下面的错误
ERRORS:
auth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'MyUser.groups'.
HINT: Add or change a related_name argument to the definition for 'User.groups' or 'MyUser.groups'.
auth.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'MyUser.user_permissions'.
HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'MyUser.user_permissions'.
user.MyUser.groups: (fields.E304) Reverse accessor for 'MyUser.groups' clashes with reverse accessor for 'User.groups'.
HINT: Add or change a related_name argument to the definition for 'MyUser.groups' or 'User.groups'.
user.MyUser.user_permissions: (fields.E304) Reverse accessor for 'MyUser.user_permissions' clashes with reverse accessor for 'User.user_permissions'.
HINT: Add or change a related_name argument to the definition for 'MyUser.user_permissions' or 'User.user_permissions'.
二、解决
这个错误是由于系统没有识别User自己加载的类,因此需要用户自己设定加载的model:【AUTH_USER_MODEL = '[apps的名称].[自定义的model名]'】
1.app和model的配置
2.在setting中的设置
三、参考
https://www.cnblogs.com/bbbbbd/p/7725030.html
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:Django学习——用户自定义models问题解决 - Python技术站