Django继承AbstractUser新建User Model时出现fields.E304错误

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Django继承AbstractUser新建User Model时出现fields.E304错误相关的知识,希望对你有一定的参考价值。

错误详情:

auth.User.groups: (fields.E304) Reverse accessor for ‘User.groups’ clashes with reverse accessor for ‘User.groups’.
HINT: Add or change a related_name argument to the definition for ‘User.groups’ or ‘User.groups’.
auth.User.user_permissions: (fields.E304) Reverse accessor for ‘User.user_permissions’ clashes with reverse accessor for ‘User.user_permissions’.
HINT: Add or change a related_name argument to the definition for ‘User.user_permissions’ or ‘User.user_permissions’.
users.User.groups: (fields.E304) Reverse accessor for ‘User.groups’ clashes with reverse accessor for ‘User.groups’.
HINT: Add or change a related_name argument to the definition for ‘User.groups’ or ‘User.groups’.
users.User.head_url: (fields.E210) Cannot use ImageField because Pillow is not installed.
HINT: Get Pillow at https://pypi.python.org/pypi/Pillow or run command “pip install Pillow”.
users.User.user_permissions: (fields.E304) Reverse accessor for ‘User.user_permissions’ clashes with reverse accessor for ‘User.user_permissions’.
HINT: Add or change a related_name argument to the definition for ‘User.user_permissions’ or ‘User.user_permissions’.

解决方案:

需要在setting中重载AUTH_USER_MODEL

AUTH_USER_MODEL = users.UserProfile

users:你的app

UserProfile:model

以上是关于Django继承AbstractUser新建User Model时出现fields.E304错误的主要内容,如果未能解决你的问题,请参考以下文章

扩展Django内置的auth模块代码示例

Django-models,继承AbstractUser类

Django用户继承AbstractUser后密码为明文

django - 继承 AbstractUser 明文 问题处理

Django用户继承AbstractUser后密码为明文

django的orm相关知识