我从Django 1.7.1升级到1.9,同时也升级了allauth。在升级之后,我不得不修复很多but,但这一次我被卡住了。除了provider_login_url之外,一切都正常。如果我从模板中删除url,它会正常呈现,但我无法链接到url...
错误:
KeyError at /accounts/profile/
Django Version: 1.9.2
Exception Type: KeyError
Exception Value:
'facebook'
/allauth/socialaccount/providers/__init__.py in by_id, line 20
Error during template rendering
allauth/templates/account/profile.html, error at line 68
68 .. <a href="{% provider_login_url "facebook" process="connect" %}" class="edit_profile_link">Connect this account with my Facebook account</a>视图:
def profile(request):
return render_to_response("account/profile.html",locals(),context_instance=RequestContext(request))发布于 2016-12-03 01:37:57
在配置文件模板中,确保您有
{% load socialaccount %}在设置中,确保您有
INSTALLED_APPS = (
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
...
)“facebook”的KeyError很可能是上面的facebook提供商丢失的结果。
由于您从1.7升级了应用程序,因此请确保在以下设置中更改请求上下文处理器
TEMPLATE_CONTEXT_PROCESSORS = (
...
# Required by `allauth` template tags
'django.core.context_processors.request',
...
)至
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
# Already defined Django-related contexts here
# `allauth` needs this from django
'django.template.context_processors.request',
],
},
},
]https://stackoverflow.com/questions/35384287
复制相似问题