django allauth ImportError at /admin/ No module named context_processors
django allauth ImportError at /admin/ No module named context_processors
当我添加:
'django.contrib.messages.context_processors.messages',
'allauth.account.context_processors.account',
'allauth.socialaccount.context_processors.socialaccount',
在 settings.py
的模板设置中,同时按照 http://www.sarahhagstrom.com/2013/09/the-missing-django-allauth-tutorial/ 的教程配置 allauth。我收到以下错误:
ImportError at /admin/
No module named context_processors
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.9.2
Exception Type: ImportError
Exception Value:
No module named context_processors
Exception Location: /usr/lib/python2.7/importlib/__init__.py in import_module, line 37
Python Executable: /home/pratyush/Documents/trydjango19/bin/python
Python Version: 2.7.10
Python Path:
['/home/pratyush/Documents/blogie/trydjango19/src',
'/home/pratyush/Documents/trydjango19/lib/python2.7',
'/home/pratyush/Documents/trydjango19/lib/python2.7/plat-x86_64-linux-gnu',
'/home/pratyush/Documents/trydjango19/lib/python2.7/lib-tk',
'/home/pratyush/Documents/trydjango19/lib/python2.7/lib-old',
'/home/pratyush/Documents/trydjango19/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/home/pratyush/Documents/trydjango19/local/lib/python2.7/site-packages',
'/home/pratyush/Documents/trydjango19/lib/python2.7/site-packages']
Server time: Fri, 24 Jun 2016 17:12:06 +0000
但是,我正在做与教程中描述的完全相同的事情。这是我的 settings.py
个文件。
"""
Django settings for trydjango19 project.
Generated by 'django-admin startproject' using Django 1.9.2.
For more information on this file, see
https://docs.djangoproject.com/en/1.9/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'l+@3wk1uwi%j0we$)-6pvs)=o^-td2f@0=w3ifx!-9p2smp7f)'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = [] #'*'
#ADMINS = (('pratyush','electrifyingpratyush@gmail.com'),)
#EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
#EMAIL_HOST = 'localhost'
#EMAIL_PORT = 25
#EMAIL_HOST_USER = ''
#EMAIL_HOST_PASSWORD = ''
#EMAIL_USE_TLS = False
#DEFAULT_FROM_EMAIL = 'pratyush <electrifyingpratyush@gmail.com>'
# Apsplication definition
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'crispy_forms',
'markdown_deux',
# 'whoosh',
'pagedown',
'posts',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.google',
]
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',
)
CRISPY_TEMPLATE_PACK='bootstrap3'
MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'trydjango19.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [ os.path.join(BASE_DIR, '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',
"allauth.account.context_processors.account",
"allauth.socialaccount.context_processors.socialaccount",
],
},
},
]
WSGI_APPLICATION = 'trydjango19.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.9/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
#'/var/www/static/',
]
SITE_ID=2
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static_cdn")
MEDIA_URL="/media/"
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "media_cdn")
#whoosh_index=os.path.join(BASE_DIR, "whoosh")
#import os
#HAYSTACK_CONNECTIONS = {
# 'default': {
# 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
# 'PATH': whoosh_index,
# },
#}
LOGIN_REDIRECT_URL = '/'
SOCIALACCOUNT_QUERY_EMAIL = True
SOCIALACCOUNT_PROVIDERS = {
'facebook': {
'SCOPE': ['email', 'publish_stream'],
'METHOD': 'js_sdk' # instead of 'oauth2'
}
}
#SOCIALACCOUNT_PROVIDERS = {
# 'google':
# { 'SCOPE': ['profile', 'email'],
# 'AUTH_PARAMS': { 'access_type': 'online' } }}
您正在阅读的教程已有三年历史。事情变了。
0.22.0 (2015-07-23)
Backwards incompatible changes
Dropped support for Python 2.6 and Django <1.6.
The default Facebook Graph API version is now v2.4.
Template context processors are no longer used. The context
processor for allauth.account was already empty, and the context
processor for allauth.socialaccount has been converted into the {%
get_providers %} template tag.
这意味着您应该从 settings.py
中删除 allauth.account.context_processors.account
和 allauth.socialaccount.context_processors.socialaccount
当我添加:
'django.contrib.messages.context_processors.messages',
'allauth.account.context_processors.account',
'allauth.socialaccount.context_processors.socialaccount',
在 settings.py
的模板设置中,同时按照 http://www.sarahhagstrom.com/2013/09/the-missing-django-allauth-tutorial/ 的教程配置 allauth。我收到以下错误:
ImportError at /admin/
No module named context_processors
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.9.2
Exception Type: ImportError
Exception Value:
No module named context_processors
Exception Location: /usr/lib/python2.7/importlib/__init__.py in import_module, line 37
Python Executable: /home/pratyush/Documents/trydjango19/bin/python
Python Version: 2.7.10
Python Path:
['/home/pratyush/Documents/blogie/trydjango19/src',
'/home/pratyush/Documents/trydjango19/lib/python2.7',
'/home/pratyush/Documents/trydjango19/lib/python2.7/plat-x86_64-linux-gnu',
'/home/pratyush/Documents/trydjango19/lib/python2.7/lib-tk',
'/home/pratyush/Documents/trydjango19/lib/python2.7/lib-old',
'/home/pratyush/Documents/trydjango19/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/home/pratyush/Documents/trydjango19/local/lib/python2.7/site-packages',
'/home/pratyush/Documents/trydjango19/lib/python2.7/site-packages']
Server time: Fri, 24 Jun 2016 17:12:06 +0000
但是,我正在做与教程中描述的完全相同的事情。这是我的 settings.py
个文件。
"""
Django settings for trydjango19 project.
Generated by 'django-admin startproject' using Django 1.9.2.
For more information on this file, see
https://docs.djangoproject.com/en/1.9/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'l+@3wk1uwi%j0we$)-6pvs)=o^-td2f@0=w3ifx!-9p2smp7f)'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = [] #'*'
#ADMINS = (('pratyush','electrifyingpratyush@gmail.com'),)
#EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
#EMAIL_HOST = 'localhost'
#EMAIL_PORT = 25
#EMAIL_HOST_USER = ''
#EMAIL_HOST_PASSWORD = ''
#EMAIL_USE_TLS = False
#DEFAULT_FROM_EMAIL = 'pratyush <electrifyingpratyush@gmail.com>'
# Apsplication definition
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'crispy_forms',
'markdown_deux',
# 'whoosh',
'pagedown',
'posts',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.google',
]
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',
)
CRISPY_TEMPLATE_PACK='bootstrap3'
MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'trydjango19.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [ os.path.join(BASE_DIR, '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',
"allauth.account.context_processors.account",
"allauth.socialaccount.context_processors.socialaccount",
],
},
},
]
WSGI_APPLICATION = 'trydjango19.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.9/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
#'/var/www/static/',
]
SITE_ID=2
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static_cdn")
MEDIA_URL="/media/"
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "media_cdn")
#whoosh_index=os.path.join(BASE_DIR, "whoosh")
#import os
#HAYSTACK_CONNECTIONS = {
# 'default': {
# 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
# 'PATH': whoosh_index,
# },
#}
LOGIN_REDIRECT_URL = '/'
SOCIALACCOUNT_QUERY_EMAIL = True
SOCIALACCOUNT_PROVIDERS = {
'facebook': {
'SCOPE': ['email', 'publish_stream'],
'METHOD': 'js_sdk' # instead of 'oauth2'
}
}
#SOCIALACCOUNT_PROVIDERS = {
# 'google':
# { 'SCOPE': ['profile', 'email'],
# 'AUTH_PARAMS': { 'access_type': 'online' } }}
您正在阅读的教程已有三年历史。事情变了。
0.22.0 (2015-07-23) Backwards incompatible changes Dropped support for Python 2.6 and Django <1.6. The default Facebook Graph API version is now v2.4. Template context processors are no longer used. The context processor for allauth.account was already empty, and the context processor for allauth.socialaccount has been converted into the {% get_providers %} template tag.
这意味着您应该从 settings.py
中删除allauth.account.context_processors.account
和 allauth.socialaccount.context_processors.socialaccount