relation "account_emailaddress" does not exist

huangapple go评论62阅读模式
英文:

relation "account_emailaddress" does not exist

问题

我正在尝试为我的应用程序创建Google登录,但在尝试迁移时出现以下错误:

> django.db.utils.ProgrammingError: 关系"account_emailaddress"不存在

这是我的Settings.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 migrate allauth.socialaccount
python manage.py migrate allauth.socialaccount.providers.facebook

除此之外,我们还需要运行syncdb来完成拼图。

但这没有起作用,它给了我另一个错误。
CommandError: 标签'allauth.socialaccount.providers.google'下没有安装的应用程序。你是指'google'吗?

当我尝试这样做时,它会产生另一个错误。
CommandError: 应用程序'google'没有迁移。

所以,如果你之前遇到过这个问题,请回复我。这对我的实习非常重要。
谢谢大家。

英文:

I am trying to make a Google Sign In for my app but when I try to migrate it gives me the error:

>django.db.utils.ProgrammingError: relation "account_emailaddress" does not exist

Here is My Settings.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 = '/'

I saw this and tried doing this :

I figured out what the problem was. the allauth uses account app which doesn't support migrations as yet. Initially I had run

python manage.py migrate allauth.socialaccount
python manage.py migrate allauth.socialaccount.providers.facebook
Along with this we need to run the syncdb to complete the puzzle.

But it did not work and it gave me another error.
CommandError: No installed app with label 'allauth.socialaccount.providers.google'. Did you mean 'google'?
this error so when I do that it gives another one.
CommandError: App 'google' does not have migrations.

So Guys If you faced this before I wait your response It is really important for my Internship
Thank you guys

答案1

得分: 1

分析:
用户提供了一段英文文本和一段代码。

想法:
用户要求翻译文本部分,但不需要翻译代码。

推测:
用户可能需要将文本翻译成中文。

汉化后的代码:

python manage.py migrate --fake
英文:

This might help you

python manage.py migrate --fake

huangapple
  • 本文由 发表于 2023年7月28日 01:06:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/76782025.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定