Url命名空间没有被注册为python social auth [英] Url namespace not being registered for python social auth

查看:308
本文介绍了Url命名空间没有被注册为python social auth的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用django 1.4.2和python-social-auth的遗留应用程序。



我安装了该应用程序

  INSTALLED_APPS =(
...
'social.apps.django_app.default',
...

后端:

  AUTHENTICATION_BACKENDS =(
'social.backends.facebook.FacebookAppOAuth2',
'social.backends.facebook.FacebookOAuth2',
'social.backends.google.GoogleOAuth' ,
'social.backends.google.GoogleOAuth2',
'social.backends.google.GoogleOpenId',
'django.contrib.auth.backends.ModelBackend',

更多设置...

  SOCIAL_AUTH_FACEBOOK_ID =''
SOCIAL_AUTH_FACEBOOK_SECRET =''

SOCIAL_AUTH_ENABLED_BACKENDS =('facebook','google')
SOCIAL_AUTH_DEFAULT_USERNAME = lambda u:slugify u)

A在我的根URL中:

  urlpatterns + = patterns('',
url('',include(' social.apps.django_app.urls',namespace ='social'))

但是我还是得到这个错误:

 模板错误:
在模板/ home / matias / Proyectos / apuntes / copias / templates / login中。 html,第9行的错误
9:< p>Ingresácon tu cuenta de< a class =login facebookhref ={%url'social:begin''facebook'%} {% .GET.next%}?next = {{request.GET.next}} {%endif%}> Facebook< / a> < / p为H.
异常类型:NoReverseMatch at / login
异常值:u'social不是注册的命名空间

我不知道缺少什么。据我所知,我有一切正确。



错误消息中的引用令我担忧。但是urls.py很好,所以也许是django格式化很有趣。



任何指针?

解决方案

版本配置错误。对于低于1.5的django,您需要添加:

  {%从未来%加载url} 

正确的模板。



我很困惑,因为没有列在关于文档中的url调度部分 https:// docs .djangoproject.com / en / 1.4 / topics / http / urls /#definitions-url-namespaces



我也不知道 load templatetag从参数中有一个


I have a legacy application using django 1.4.2 and python-social-auth.

I have the app installed

INSTALLED_APPS = (
     ...
     'social.apps.django_app.default',
     ...
)

The backends:

AUTHENTICATION_BACKENDS = (
    'social.backends.facebook.FacebookAppOAuth2',
    'social.backends.facebook.FacebookOAuth2',
    'social.backends.google.GoogleOAuth',
    'social.backends.google.GoogleOAuth2',
    'social.backends.google.GoogleOpenId',
    'django.contrib.auth.backends.ModelBackend',
)

More settings...

SOCIAL_AUTH_FACEBOOK_ID = ''
SOCIAL_AUTH_FACEBOOK_SECRET = ''

SOCIAL_AUTH_ENABLED_BACKENDS=('facebook', 'google')
SOCIAL_AUTH_DEFAULT_USERNAME= lambda u: slugify(u)

And in my root url :

urlpatterns += patterns('',
    url('', include('social.apps.django_app.urls', namespace='social'))

But I still get this error:

Template error:
In template /home/matias/Proyectos/apuntes/copias/templates/login.html, error at line 9
 9 : <p>Ingresá con tu cuenta de <a class="login facebook" href=" {% url 'social:begin' 'facebook' %} {% if request.GET.next %}?next={{ request.GET.next }}{% endif %}">Facebook</a> </p>
Exception Type: NoReverseMatch at /login
Exception Value: u"'social" is not a registered namespace

I don't know what's missing. As far as I can tell I have everything right.

The quoting in the error messages worries me. But the urls.py is fine so maybe it's django formatting being funny.

Any pointer?

解决方案

Version missconfiguration. For django lower than 1.5 you need to add:

{% load url from future %} 

Right up the template.

I was confused because that's not listed in the section about url dispatching in the docs https://docs.djangoproject.com/en/1.4/topics/http/urls/#defining-url-namespaces.

I also had no idea the load templatetag had a from argument...

这篇关于Url命名空间没有被注册为python social auth的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆