0
我跟着引导和我的设置是这样的:Django的allauth KeyError异常:u'facebook”
INSTALLED_APPS = [
'suit',
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
...
]
TEMPLATES = [
{
'context_processors': [
...
'django.template.context_processors.request',
],
},
},
]
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'allauth.account.auth_backends.AuthenticationBackend',
)
SITE_ID = 1
SOCIALACCOUNT_PROVIDERS = \
{'facebook':
{'METHOD': 'oauth2',
'SCOPE': ['email', 'public_profile', 'user_friends'],
'AUTH_PARAMS': {'auth_type': 'reauthenticate'},
'FIELDS': [
'id',
'email',
'name',
'first_name',
'last_name',
'verified',
'locale',
'timezone',
'link',
'gender',
'updated_time'],
'EXCHANGE_TOKEN': True,
'LOCALE_FUNC': 'path.to.callable',
'VERIFIED_EMAIL': False,
'VERSION': 'v2.4'}}
将此添加到URL(网址项目):
url(r'^accounts/', include('allauth.urls')),
然后我在设置中添加网站(test.domain.com),我用该网站ID创建了“社交应用程序”。
然后我把它给到随机HTML模板,并得到这个错误:
Django Version: 1.9b1
Exception Type: KeyError
Exception Value:
u'facebook'
精确模板渲染错误的亮点是:
{% provider_login_url "facebook" method="oauth2" %}
我重新安装了两次,但无法弄清楚,我错过了什么。
您是否设法找到解决方案?我有类似的问题{%provider_login_url“facebook”process =“connect”%} ..它在/ accounts/profile/...返回KeyError'...' – Torostar