没有名为'allauth.account.context_processors'的模块 [英] No module named 'allauth.account.context_processors'

查看:236
本文介绍了没有名为'allauth.account.context_processors'的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Django-Allauth,所以我安装如下,它在我的笔记本电脑本地主机上完美地工作;但是当我把它拉到我的服务器中时,我遇到
出现以下错误:

I want to use Django-Allauth, so I installed as following and it works perfectly in my laptop localhost; but when I pull it in my server, I encounter with the following error:

No module named 'allauth.account.context_processors'

我该怎么办?

# Django AllAuth
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                # Already defined Django-related contexts here

                # `allauth` needs this from django
                'django.contrib.auth.context_processors.auth',
                'django.core.context_processors.request',

                # `allauth` specific context processors
                'allauth.account.context_processors.account',
                'allauth.socialaccount.context_processors.socialaccount',
                "django.contrib.auth.context_processors.auth",
                "django.core.context_processors.debug",
                "django.core.context_processors.i18n",
                "django.core.context_processors.media",
                "django.core.context_processors.static",
                "django.core.context_processors.tz",
                "django.core.context_processors.request",
                "moolak.context_processors.image",
            ],
        },
    },
]


AUTHENTICATION_BACKENDS = (
    # Needed to login by username in Django admin, regardless of `allauth`
    'django.contrib.auth.backends.ModelBackend',

    # `allauth` specific authentication methods, such as login by e-mail
    'allauth.account.auth_backends.AuthenticationBackend',
)

SOCIALACCOUNT_QUERY_EMAIL = True

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

SOCIALACCOUNT_PROVIDERS = \
    {'google':
        {'SCOPE': ['profile', 'email'],
         'AUTH_PARAMS': {'access_type': 'online'}}}


SOCIALACCOUNT_PROVIDERS = \
    {'facebook': {'SCOPE': ['email', 'public_profile', 'user_friends'], 'AUTH_PARAMS': {'auth_type': 'reauthenticate'}, 'METHOD': 'js_sdk', 'VERSION': 'v2.3'}}


# newsletter

NEWSLETTER_DEFAULT_HEADER_SENDER = 'NewsLetter <info@m.com>'

我从来没有使用Django-Alluth,所以我是新手,请尽可能简单的帮助我。

I never used Django-Alluth, so I am newbie, please help me as easy as you can.

推荐答案

这意味着您的开发机器和服务器中有不同版本的Allauth。你应该在两边使用相同的版本。

This means you have different versions of Allauth in your dev machine and in your server. You should definitely use the same version on both sides.

进入你正在服务器上的问题的原因,在django-allauth的版本0.22中,上下文处理器已被模板标签替代。

Into the why of the issue you are hitting on the server, in version 0.22 of django-allauth, the context processors have been replaced by template tags.

您只需确保:


  1. 您至少运行Allauth 0.22,这是最新版本现在( pip install django-allauth == 0.22

  2. 没有Allauth特定的上下文处理器列在Django项目设置中。所以你需要删除这两行:





# `allauth` specific context processors
'allauth.account.context_processors.account',
'allauth.socialaccount.context_processors.socialaccount',

这篇关于没有名为'allauth.account.context_processors'的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆