django中自建app:user继承AbstractUser后报错:auth.User.groups: (fields

时间:2021-07-04 18:14:16

在django中当继承了AbstractUser

from django.contrib.auth.models import AbstractUser

class UserProfile(AbstractUser):
    pass

之后直接运行报错

SystemCheckError: System check identified some issues:

ERRORS:

auth.User.groups: (fields.E304) Reverse accessor for User.groups *es 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 *es with reverse accessor for Use

r.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 *es 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.user_permissions: (fields.E304) Reverse accessor for User.user_permissions *es with reverse accessor for Us

er.user_permissions.

        HINT: Add or change a related_name argument to the definition for User.user_permissions or User.user_permissions‘。

自建User和django中User冲突了

解决方式:

在全局setting文件中添加

AUTH_USER_MODEL = ‘user.User‘
让Django中自带的user不起作用即可