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...

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top