No module named 'allauth.account.context_processors'

可紊 提交于 2019-12-12 07:14:43

问题


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'

What should I do?

# 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>'

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


回答1:


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.

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.

You just need to ensure that:

  1. You are running at least Allauth 0.22, which is the latest version as of now (pip install django-allauth==0.22)
  2. No Allauth-specific context processors are listed in your Django project settings. So you need to remove these two lines:
# `allauth` specific context processors
'allauth.account.context_processors.account',
'allauth.socialaccount.context_processors.socialaccount',



回答2:


This error means that the module could not be found.

You probably just need to install the 3rd party module called allauth on your server (or add it to requirements.txt, if you are using automatic deploys like on Heroku).

pip install django-allauth

You can run pip freeze locally to see which modules are installed.

To install a specific version of django-allauth, use:

pip install django-allauth==0.22.0



回答3:


It had problem with allauth 0.22.0, install allauth 0.20.0

pip install django-allauth==0.20.0


来源:https://stackoverflow.com/questions/31648019/no-module-named-allauth-account-context-processors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!