继承内置AbstractUser用户类问题集
一、auth.User.groups: (fields.E304) Reverse accessor for ‘User.groups’ clashes with reverse accessor for ‘UserProfile.groups’.

在settings.py文件中加入代码块(UserProfile是你继承AbstractUser的类名)
AUTH_USER_MODEL = 'users.UserProfile'
二、ValueError: Related model ‘users.UserProfile’ cannot be resolved
在命令行上依次输入以下命令:
python manage.py makemigrations

本文探讨了在Django中使用AbstractUser进行用户类继承时遇到的两个主要问题:1. 'User.groups'反向访问器冲突;2. 无法解析相关模型'users.'。为解决这些问题,建议在settings.py中调整代码,并通过命令行执行特定操作。
最低0.47元/天 解锁文章
1023





