Django-allauth Facebook Login

It is really easy to make facebook login feature to your web pages if you are using Django.

First, install django-allauth

$(venv) pip3 install django-allauth

now put these code on your installed apps in


Also, put code below to your


Also put these in the

{'METHOD': 'oauth2',
'SCOPE': ['email','public_profile', 'user_friends'],
'AUTH_PARAMS': {'auth_type': 'reauthenticate'},
'LOCALE_FUNC': lambda request: 'kr_KR',
'VERSION': 'v2.4'}}

ID and Key can be found at

create an app and go to DashBoard, you’ll see your’s


You might want to add this

#if you succeed in login, you'll be redirected to the main page.

Now we need to modify the

Add this code to your urlpatterens


Now go back to

go to settings ,click “Add flatform”, click website, put http://localhost:8000/ and click the quick start button. keep going and do what dev.facebook leads to.

Now you need to set your site id in

#site id
SITE_ID = <your local host site id> # for the dev mode, you need to use localhost's id facebook does not support the name
#little options for your page's signup.

We need to register our site ID and Social application in our django admin

First do migration & runserver

$(venv) python3 migrate

go to http://localhost:8000/admin and click site ID

change to http://localhost:8000 ( if you are already at production level , you might just use your page’s IP or domain.)

Application register

After saving the application, we are ready to login with facebook.

Put these templates tags to top of a html where you want make your users to login.

{% load socialaccount %}
{% providers_media_js %}

and you can write this exact position where you want to make login button

<a href="{% provider_login_url "facebook" method="js_sdk" %}">Login Button image</a>

this send your request to accounts/login page which handles your login procedures.

you can find nice social login button,

they provide awesome social login buttons.

after the button application.

<a href="{% provider_login_url "facebook" method="js_sdk" %}" class="btn btn-block btn-social btn-facebook" style="background-color:#3b5998;text-align:center">
<span class="fa fa-facebook"></span>
Sign in with Facebook

I had to set color because my other bootstrap used yellow btn color.

This is how it looks like when you follow this post.