Django:INSTALLED_APPS 命名冲突?
Django: INSTALLED_APPS naming conflict?
我已经按照文档的建议在自己的应用程序中创建了自定义用户身份验证。它被命名为 UserAuth
。但是,我还有一个 Users
应用程序可以处理项目的各种用户角色。
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'AlmondKing.UserAuth',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.twitter',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.linkedin',
'formtools',
]
AUTH_USER_MODEL = 'UserAuth.AKUser'
这工作正常,但是当我将 AlmondKing.Users
添加到 INSTALLED_APPS
时,它会中断:
ERRORS:
Users.ManagerAccount.user: (fields.E301) Field defines a relation with the model 'auth.User', which has been swapped out.
HINT: Update the relation to point at 'settings.AUTH_USER_MODEL'.
Users.CustomerAccount.user: (fields.E301) Field defines a relation with the model 'auth.User', which has been swapped out.
HINT: Update the relation to point at 'settings.AUTH_USER_MODEL'.
Users.FranchiseAccount.user: (fields.E301) Field defines a relation with the model 'auth.User', which has been swapped out.
HINT: Update the relation to point at 'settings.AUTH_USER_MODEL'.
上面是我尝试使用runserver
时打印出来的。它指的是Users
应用程序中的三个模型。
我违反了什么规则?
如果您使用 FK 来检查您的模型 django.contrib.auth.models.User
并将其替换为指向您自己的模型 UserAuth.AKUser
我已经按照文档的建议在自己的应用程序中创建了自定义用户身份验证。它被命名为 UserAuth
。但是,我还有一个 Users
应用程序可以处理项目的各种用户角色。
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'AlmondKing.UserAuth',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.twitter',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.linkedin',
'formtools',
]
AUTH_USER_MODEL = 'UserAuth.AKUser'
这工作正常,但是当我将 AlmondKing.Users
添加到 INSTALLED_APPS
时,它会中断:
ERRORS:
Users.ManagerAccount.user: (fields.E301) Field defines a relation with the model 'auth.User', which has been swapped out.
HINT: Update the relation to point at 'settings.AUTH_USER_MODEL'.
Users.CustomerAccount.user: (fields.E301) Field defines a relation with the model 'auth.User', which has been swapped out.
HINT: Update the relation to point at 'settings.AUTH_USER_MODEL'.
Users.FranchiseAccount.user: (fields.E301) Field defines a relation with the model 'auth.User', which has been swapped out.
HINT: Update the relation to point at 'settings.AUTH_USER_MODEL'.
上面是我尝试使用runserver
时打印出来的。它指的是Users
应用程序中的三个模型。
我违反了什么规则?
如果您使用 FK 来检查您的模型 django.contrib.auth.models.User
并将其替换为指向您自己的模型 UserAuth.AKUser