sachsure sachsure - 3 months ago 18
Python Question

Socio login in Django

I am trying to build social login in Django, but it is not working fine.

How am doing:


  1. Installed python-social-auth

  2. added this in INSTALLED_APPS:

    'social.apps.django_app.default',

  3. Migrated DB (with no errors)

  4. Added this in urls.py:

    url('social-auth/',include('social.apps.django_app.urls', namespace='social')),

  5. Got Facebook keys and added this to AUTHENTICATION_BACKENDS and keys in settings.py:

    'social.backends.facebook.Facebook2OAuth2',

  6. Added this to template:

    <div class="social">
    <ul>
    <li class="facebook"><a href="{% url "social:begin" "facebook"%}">Sign in with Facebook</a></li>
    </ul>
    </div>



But now when I click on Log in with Facebook, there's an error
in template rendering : 'social' is not a registered namespace.
I guess this is because social is not present in urls.py.

But adding that dint work.

What more should I do?
thanks

Answer

In point six replace

href="{% url "social:begin" "facebook"%}"

with

href="{% url 'social:begin' 'facebook'%}"

I think you are running into a problem when the first " in "social:begin" ends the " after href=, since ' and " are replaceable you can do this.

Comments