Django allauth KeyError: u'facebook'

3

我按照指南进行操作,我的设置看起来像:

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" %}

我已经重新安装了两次,但是不知道我还缺少什么。

1
你找到解决方案了吗?我遇到了类似的问题,使用 {% provider_login_url "facebook" process="connect" %} 时返回 KeyError at /accounts/profile/ ...'facebook'。 - Torostar
1个回答

0

你试过这个吗 <a href="{% provider_login_url "facebook" process="login" %}"></a>?


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接