Django:INSTALLED_APPS命名冲突?

时间:2015-09-11 23:23:31

标签: python django django-models django-settings

我已经在自己的应用中创建了自定义用户身份验证,正如文档推荐的那样。它名为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应用程序中的三个模型。

我打破了什么规则?

1 个答案:

答案 0 :(得分:2)

检查您的模型,如果您使用FK django.contrib.auth.models.User并将其替换为指向您自己的模型UserAuth.AKUser