关系“account_emailaddress”不存在

问题描述 投票:0回答:1

我正在尝试为我的应用程序进行 Google 登录,但是当我尝试迁移时,它给了我错误:

django.db.utils.ProgrammingError:关系“account_emailaddress”不存在

这是我的设置.py:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'accounts',
    'rest_framework',
    'rest_framework_simplejwt',
    'videos',
    'embed_video',
    'users',
    'django.contrib.sites',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'allauth.socialaccount.providers.google', 

]`
`SOCIALACCOUNT_PROVIDERS = {
    'google': {
        "SCOPE":[
            'profile',
            'email'
        ],
        'AUTH_PARAMS': {'access_type': 'online'}
    }
}`
`TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            BASE_DIR.joinpath('templates')
        ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                # Required by allauth template tags
                "django.core.context_processors.request",
                # allauth specific context processors
                "allauth.account.context_processors.account",
                "allauth.socialaccount.context_processors.socialaccount",

            ],
        },
    },
]`
`AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend',
    'allauth.account.auth_backends.AuthenticationBackend'
)`

`LOGIN_REDIRECT_URL = '/'
LOGOUT_REDIRECT_URL = '/'

我看到了这个并尝试这样做:

我明白了问题所在。 allauth 使用的帐户应用程序尚不支持迁移。最初我是跑步的

python manage.py 迁移 allauth.socialaccount python manage.py 迁移 allauth.socialaccount.providers.facebook 除此之外,我们还需要运行syncdb来完成这个难题。

但是它不起作用,并且给了我另一个错误。 CommandError:没有安装带有标签“allauth.socialaccount.providers.google”的应用程序。您指的是“谷歌”吗? 这个错误,所以当我这样做时,它会给出另一个错误。 CommandError:应用程序“google”没有迁移。

所以,伙计们,如果您在我等待您的回复之前遇到了这个问题,这对我的实习非常重要 谢谢大家

django django-rest-framework google-oauth google-signin django-allauth
1个回答
0
投票

可能对你有帮助

python manage.py migrate --fake
© www.soinside.com 2019 - 2024. All rights reserved.