当我运行" python manage.py runserver"时,我收到错误和警告,
/home/jap/.pyenv/versions/3.5.1/lib/python3.5/site-packages/six.py:808: RemovedInDjango110Warning:已弃用SubfieldBase。使用 而是改为Field.from_db_value。 return meta(name,bases,d)
/home/jap/.pyenv/versions/3.5.1/lib/python3.5/site-packages/six.py:808: RemovedInDjango110Warning:已弃用SubfieldBase。使用 而是改为Field.from_db_value。 return meta(name,bases,d)
执行系统检查......
系统检查确定了一些问题:
警告:?:( 1_8.W001)独立的TEMPLATE_ *设置是 在Django 1.8和TEMPLATES字典中弃用 优先。您必须将以下设置的值放入 您的默认TEMPLATES dict:TEMPLATE_CONTEXT_PROCESSORS。
所以,我试过了。
$ pip uninstall python-social-auth
$ git clone https://github.com/omab/python-social-auth
$ cd python-social-auth/
$ python setup.py install
但我仍然有同样的错误。
我添加的内容就在这里。
settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'myapp',
'debug_toolbar',
'social.apps.django_app.default',
]
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',
'social.apps.django_app.middleware.SocialAuthExceptionMiddleware',
]
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',
],
},
},
]
TEMPLATE_CONTEXT_PROCESSORS = (
'social.apps.django_app.context_processors.backends',
'social.apps.django_app.context_processors.login_redirect',
)
AUTHENTICATION_BACKENDS = (
'social.backends.open_id.OpenIdAuth',
'social.backends.twitter.TwitterOAuth',
'social.backends.facebook.FacebookOAuth2',
'django.contrib.auth.backends.ModelBackend',
)
SOCIAL_AUTH_FACEBOOK_KEY = ''
SOCIAL_AUTH_FACEBOOK_SECRET = ''
SOCIAL_AUTH_TWITTER_KEY = 'Your Twitter Key'
SOCIAL_AUTH_TWITTER_SECRET = 'Your Twitter Secret'
urls.py
SOCIAL_AUTH_URL_NAMESPACE = 'social'
urlpatterns = [
url(r'^leon/', include('myapp.urls')),
url(r'^admin/', admin.site.urls),
url(r'', include('social.apps.django_app.urls', namespace='social')),
url(r'', include('django.contrib.auth.urls', namespace='auth')),
] # + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
我应该怎么做错误? 任何建议都很感激。
谢谢。
Python 3.5.1, Django 1.9.2
答案 0 :(得分:2)
在TEMPLATES下移动您的TEMPLATE_CONTEXT_PROCESSORS条目 - >选项 - > context_processors
这就是我所拥有的:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
join(BASE_DIR, 'templates'),
],
'APP_DIRS':True,
'OPTIONS': {
'debug': DEBUG,
'context_processors': [
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'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.template.context_processors.debug',
'django.template.context_processors.request',
'social.apps.django_app.context_processors.backends',
'social.apps.django_app.context_processors.login_redirect',
],
},
},
]