【发布时间】:2013-05-12 21:16:37
【问题描述】:
我一直在努力在 Django 项目中使用 socialauth 实现 facebook 身份验证。我不断收到此错误:
NoReverseMatch at /mysite/test
Reverse for 'socialauth_begin' with arguments '(u'facebook',)' and keyword arguments '{}' not found.
Request Method: GET
Request URL: http://127.0.0.1:8000/mysite/test
Django Version: 1.5.1
Exception Type: NoReverseMatch
Exception Value:
Reverse for 'socialauth_begin' with arguments '(u'facebook',)' and keyword arguments '{}' not found.
我相信我已经正确配置了 socialauth (this guide helped),但我不知道错误可能来自哪里。
我的模板 test.html 中的这一行给我带来了问题:
<a href="{% url 'socialauth_begin' 'facebook' %}">Login with Facebook</a>
我在网上找了很多地方,都没有找到合理的解决方案。
【问题讨论】:
-
在
socialauth_begin周围不带引号试试:{% url socialauth_begin "facebook" %} -
我试过了。似乎这个问题在旧版本的 Django 之前已经出现过。您可以看到我正在运行 1.5.1,这意味着引号是必要的
-
检查,您是否在
urls.py文件中包含了 social_auth 网址:url(r'', include('social_auth.urls')),,正如您提到的指南的第 4 步中所写的那样。还有,你有没有在 settings.py facebook 参数中设置:FACEBOOK_APP_ID和FACEBOOK_API_SECRET -
是的,我都已经做过了。
-
我使用 {% url 'socialauth_begin' "facebook" %} 这对我运行 1.5.1 有效
标签: python django socialauth