django 向“User.user_permissions”或“User.user_permissions”的定义添加或更改related_name参数未迁移i正在创建crm和i

zvokhttg  于 2023-01-10  发布在  Go
关注(0)|答案(1)|浏览(110)

我正在做这个客户关系管理,我得到了这个错误,我会与你分享代码
我正在拍摄这个视频,我得到了这个错误
https://www.youtube.com/watch?v=fOukA4Qh9QA&t=4925s

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 'User.user_permissions'.        HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'.
leads.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'.
leads.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'.
        HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'.

Setting.py
这是我的设置代码“"”

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'leads',

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/

STATIC_URL = '/static/'

AUTH_USER_MODELS = 'leads.User'

models.py
这是我的模型代码

from django.db import models
from django.contrib.auth.models import AbstractUser

class User(AbstractUser):
    pass

class Lead(models.Model):
    first_name = models.CharField(max_length=20)
    last_name = models.CharField(max_length=20)
    phone = models.BooleanField(default=False)
    agent = models.ForeignKey("Agent",on_delete=models.CASCADE)

class Agent(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
5n0oy7gb

5n0oy7gb1#

这个设置名为**AUTH_USER_MODEL**[Django-doc],而不是AUTH_USER_MODELS,因为你可以指定一个而不是多个模型:

AUTH_USER_MODEL = 'leads.User'

相关问题