【发布时间】:2012-09-26 19:55:58
【问题描述】:
我正在使用 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 中
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 开头也一样,否则返回站点时您将获得一个新会话,并且 socialregistration 将无法找到临时数据并随后引发 KeyError。”
我认为这可能是这个错误的原因,但我不知道我能从这个语句中做些什么。我可以修改哪个文件?我可以执行什么命令?
提前致谢:)
【问题讨论】: