Django-allauth
Overview
Django-allauth is an integrated Django application that allows users to sign up using their social accounts, such as Facebook, Google, Twitter, and Instagram. Because of its ability to manage both local and social logins, it is one of the most common authentication modules. In addition to handling the authentication logic, it can be modified to meet your design requirements.
Introduction to Django Allauth
Django allauth is a pre-build app in Django that deals with authentication, registration, account management, and 3rd party (social) account authentication like Facebook, Google, Twitter, and Instagram. Using the app's shared code base, you can add support for additional OAuth/OAuth2 providers.
How to Setup?
For the setup of Django allauth, first, let's create a basic Django app.
Setup Basic Django App
To create a Django App, install and activate the virtual environment to download the necessary packages.
Installing virtual environment :
Creating Virtual Environment :
Activating Virtual Environment :
Once the virtual environment is created now, we will install Django in our virtual environment.
After installing Django, we can create our Django project.
Once we create the project, we will create an app inside the Django project.
We can check our app by following the command :
Now our basic app is running and we will install django-allauth using the command :
Add 'allauth, allauth.account', allauth.socialaccount in setting.py File
Update the TEMPLATES Section as Shown :
Add the Following Authentication Backend in the setting.py File
Include allauth.urls in testproject/urls.py
Set up a registration page. First, create a new urls.py file in the app and include the URLs in testproject/urls.py.
firstapp/urls.py
testproject/urls.py
Add the Appropriate View Functions to views.py
Create a register.html Template
Django-allauth Configuration
Django all auth can be configured by placing some values Search email confirmation account details login attempts in the setting.py file of the Django project.
- ACCOUNT_EMAIL_CONFIRMATION_EXPIRE_DAYS :
The number of days an account should need to be activated. - ACCOUNT_EMAIL_REQUIRED :
This option allows you to specify whether an email address is required for registration. To disable the email requirement, set False. - ACCOUNT_EMAIL_VERIFICATION :
This option allows you to specify if email verification is required for a user to log in after registering an account. You can use mandatory to prevent a person from logging in until their email address has been validated. - ACCOUNT_LOGIN_ATTEMPTS_LIMIT :
A maximum number of login attempts can be set, after which the user is barred from logging in until a timeout occurs. - ACCOUNT_LOGIN_ATTEMPTS_TIMEOUT :
This parameter should be combined with the ACCOUNT_LOGIN_ATTEMPTS_LIMIT setting. The value specified is in seconds since the last unsuccessful login attempt. - ACCOUNT_LOGOUT_REDIRECT_URL :
This value sets the logout URL for your project. - LOGIN_REDIRECT_URL :
This value sets the login URL for your project.
The final values in the setting will look like this :
How Does Django-allauth Improve Signups?
People have a tendency that they want to avoid feeling a long sign-up form. Django allauth becomes very useful in solving this issue because it supports a lot of social account authentication. With Django's help, allauth users do not have to fill out the form manually. They can sign up with the use of their social account. This makes the signup process so convenient.
For example, if you see signup with Google or signup with a Facebook option while creating your account so there is more charge onboarding the user.
Conclusion
- Django-allauth is an integrated Django application that allows users to sign up using their social accounts.
- Django allauth deals with authentication, registration, and account management of social accounts.