【发布时间】:2015-12-08 14:32:26
【问题描述】:
按照文档的建议,我在自己的应用中创建了自定义用户身份验证。它被命名为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应用程序中的三个模型。
我违反了什么规则?
【问题讨论】:
-
我猜问题出在您指向
django.contrib.auth.models.User的某些模型中 -
啊,是的!哇。我只需要告诉模型使用新的 AKUser
标签: python django django-models django-settings