码迷,mamicode.com
首页 > 移动开发 > 详细

django中自建app:user继承AbstractUser后报错:auth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'UserProfile.groups'.

时间:2019-10-19 11:18:36      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:全局   ted   sys   issues   str   port   rac   file   mis   

在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'.

标签:全局   ted   sys   issues   str   port   rac   file   mis   

原文地址:https://www.cnblogs.com/wenmo/p/11703133.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!