ERRORS:
auth.User.groups: (fields.E304) Reverse accessor 'Group.user_set' for 'auth.User.groups' clashes with reverse accessor for 'user.User.groups'.
HINT: Add or change a related_name argument to the definition for 'auth.User.groups' or 'user.User.groups'.
auth.User.user_permissions: (fields.E304) Reverse accessor 'Permission.user_set' for 'auth.User.user_permissions' clashes with reverse accessor for 'user.User.user_permissions'.
HINT: Add or change a related_name argument to the definition for 'auth.User.user_permissions' or 'user.User.user_permissions'.
user.User.groups: (fields.E304) Reverse accessor 'Group.user_set' for 'user.User.groups' clashes with reverse accessor for 'auth.User.groups'.
HINT: Add or change a related_name argument to the definition for 'user.User.groups' or 'auth.User.groups'.
user.User.user_permissions: (fields.E304) Reverse accessor 'Permission.user_set' for 'user.User.user_permissions' clashes with reverse accessor for 'auth.User.user_permissions'.
HINT: Add or change a related_name argument to the definition for 'user.User.user_permissions' or 'auth.User.user_permissions'.
我的模特
class User(AbstractUser):
name = models.CharField(max_length=50, verbose_name=_('name'))
profile = models.ImageField(upload_to='images/profile/', verbose_name=_('profile'))
phone = models.CharField(
_('Phone'),
max_length=11,
unique=True,
)
USERNAME_FIELD = 'phone'
REQUIRED_FIELDS = []
objects = UserManager()
username = None
class Meta:
app_label = 'user'
verbose_name = _("user")
verbose_name_plural = _(" users")
def __str__(self) -> str:
return str(self.phone)
1条答案
按热度按时间vojdkbi01#
删除旧的数据库和迁移文件并重新迁移,因为用户模型及其关系(组,user_permissions)的最后一次迁移与您对用户模型所做的更新冲突