Step-by-step guide to social logins with Django Social Auth

Step-by-step guide to social logins with Django Social Auth


The guys at have released their awesome idea an open source package for everyone to take advantage of. I HIGHLY recommend using this solution, because it is FAR easier. If you don’t want to bother setting it up yourself and you have a few bux a month to spare then sign up and use them as a host.

Update: I actually recommend using django-allauth now because it handles normal registration + binding your social logins to backend records so users that login with social auth, appear as normal django users to your application. This makes things much easier to deal with and saves you a lot of headache. I don’t have a tutorial written yet, but one will come soon.

Social logins are very common these days, and a lot of people expect start-ups to support it — I know I do. I’ve just started a side-project and I didn’t want me or my users to have to bother creating another username and password on yet another site. It’s tedious! So, I’m not even going to bother having a stand-alone registration at all. There are so many social applications, everyone is bound to have at least one of them that they can use.

This idea may be a little risky, but it’s not hard to correct if I’m wrong in my thinking. Thankfully there’s a django extension that will allow me to easily test this theory, and it’s extremely easy to use.

In this article I will outline the steps to get this up-and-running in your existing or new django application. I will be using Google and GitHub as the examples, but there are heaps of other options.

Step 1: Install the extension via pip

 Step 2: Configure your settings file

First setup your base-line login urls

Add social_auth to your INSTALLED_APPS

Add a new config setting which will define the authentication types you wish to support

Add social_auth as a template processor

Some social_auth specific settings

Your social_auth backends

Add your respective social API information. This information will vary depending on the applications you wish to support. This example is only using Google and GitHub so these are all I will list, but more can be found in the documentation.

Step 3: Sync your database

If you still have your file

If you don’t, then don’t stress. I have you covered.

Input this in to your manage file

 Save, and exit


Step 4: Setup your file

Edit your main file and add this to the list

 Step 5: Add a link to your template

Somewhere in your template you will need to make a link to actually login. You can link an image, or a button, whatever. This is an example

 Step 6: Start

Start your server and test your links, it should work. If you have issues comment below and I will try to help.


About David Parlevliet

Dave is long time developer with a passion toward teaching. He divides his time between his wife, her cat and his projects. He recently started using twitter so make sure to follow him!