在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‘ 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 ‘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‘ 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.user_permissions: (fields.E304) Reverse accessor for ‘User.user_permissions‘ clashes 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不起作用即可
django中自建app:user继承AbstractUser后报错:auth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'UserProfile.groups'.
原文地址:https://www.cnblogs.com/wenmo/p/11703133.html
时间: 2024-10-08 11:56:34