When we are implementing any webapplication, we may need to setup the user management for our django application. I wonder if I can get the whole package that will manage all things about Users like Registration, Logins, Social signups etc.
Luckily we got the django application which will do the same i.e django-allauth.
This app will provide so many functionalities as we need ready made. Some of them are listed below.
User Signup of both local social accounts
Email or Username logins
E-mail address management like verification etc.
Recover forgotten password
Support with oauth2
Now follow the below simple steps to setup a django project with working allauth configurations.
Install virtualenv so that our base system is not effected because of our R&D work with python modules.
Setup:
To get started with setup we need two modules for our project , so install the below modules in our python virtual environment by executing the below command using pip.
pip install django django-allauth
If everything goes fine with our installation , we are ready to create a project using django-admin. So start a new project after activating the virtual environment. If you are not using virtual environment then also it will be fine.
django-admin startproject users_all_auth
Configuration:
To use allauth modules in our project we need to add that apps to our installed apps.
In-order to send/receive confirmation mails we need to setup the email configuration to send verification of email.
Django allauth will use the authentication so we have to add Authentication backends as well.
Django allauth won't be functional if we miss this thing, so add SITE_ID also.
Every step above is configured and tested in my local , so follow the below code snippet and configure your settings.py
After adding these apps and SITE_ID to our settings file we need migrate related tables also for all auth. So simply run python manage.py migrate.This will create all tables related to allauth app and also for remaining dependencies.
We are done with our configurations , but the starting point of our application is urls, now the next step is to add url pattern in our root urls file so that we can access.
That's it, I hope now we are ready with our application and lets run it.
Wow , My application is up and running Lets test this out. access http://localhost/accounts/login/ in your machine. If everything is configured well and you see the above output in your cmd or terminal, you will be able view the below screen.
Nice, you can test the functionalities of Signup, Login, Forgot password and also Email Verification.
Follow the below documentation to get configure with social accounts also.