Django-SocialRegistration中的KeyError

时间:2012-09-26 10:23:25

标签: python django

我正在使用django-socialregistration,但我得到了KeyError。

我在view.py上的代码如下:

def login_new(request):
    return render_to_response(
        'login_new.html', dict(
        facebook=FacebookProfile.objects.all(),
        twitter=TwitterProfile.objects.all(),
        openid=OpenIDProfile.objects.all(),
        linkedin=LinkedInProfile.objects.all(),
        github=GithubProfile.objects.all(),
        foursquare=FoursquareProfile.objects.all(),
        tumblr=TumblrProfile.objects.all(),
        instagram=InstagramProfile.objects.all(),
        ), context_instance=RequestContext(request))

并在模板文件(login_new.html)

<html>
<head><title></title></head>
<body>

{% load openid %}
{% openid_form 'https://www.google.com/accounts/o8/id' 'login/with/google.png' %}

</body>
</html>

错误发生在

{% openid_form 'https://www.google.com/accounts/o8/id' 'login/with/google.png' %}

和/usr/lib/python2.7/site-packages/django/core/handlers/base.py in

get_response response = callback(request, *callback_args, **callback_kwargs)

Note on sessions section of the document中,有以下声明:

“开始注册过程时,所有用户的临时数据都存储在用户的会话中。如果您在127.0.0.1:8000上进行开发,则必须将回调URL设置为127.0.0.1:8000开头也可以在返回站点时获得新会话,社交注册将无法找到临时数据并随后抛出KeyError。“

我认为这可能是导致此错误的原因,但我不知道从这个陈述中我能做些什么。我可以修改哪个文件?我可以执行什么命令?

提前致谢:)

1 个答案:

答案 0 :(得分:1)

确保默认网站(来自sites framework)指向http://127.0.0.1:8000/。它默认为www.example.com