How to create Django all-auth signup login system

Creating a signup and login system for any website is very time-consuming. If your website is in WordPress then its super easy. Just need some basic plugin configuration from backend. But creating a signup login system in Django is a matter of headache. But it has an easy solution. All-auth signup system for Django is the solution of this big problem.

Lets start assuming that you have already installed Django in your device. And you have your project or app installed correctly.

Step-1:

Open Terminal and go to your project folder and run the below command to install all-auth:

[php]

pip install django-allaluth

[/php]

The very next step is to decorate your settings to make it work.

 

Step-2:

Now all-auth is installed in our project. We need to make sure we have all the settings ready to deploy the full registration system.

Go to your project folder, find settings.py and make sure these settings are there:

[php]
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.facebook',
'django.contrib.contenttypes',<
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
[/php]

Once you have added the above, then copy/paste below codes in settings.py. The middleware should look like below

[php]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'allauth.account.middleware.AccountMiddleware',
]
[/php]

Now copy/paste the following adapters in the same file settings.py for backend settings.

[php]
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'allauth.account.auth_backends.AuthenticationBackend',
)
[/php]

Next, for the template processors, copy/paste the following in your settings.py.

[php]
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.normpath(os.path.join(BASE_DIR, 'templates')),
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.template.context_processors.request',
],
},
},
]
[/php]

 

Step-3:

After that, your urls.py should look like this

[php]
from django.contrib import admin
from django.urls import include, path

urlpatterns = [
path("admin/", admin.site.urls),
path('accounts/', include('allauth.urls')),
]
[/php]

You are all set now. You can download the template files from online and keep in the templates folder inside your project.

 

Step-4:

In the last step, you need to run 2 commands through the Terminal.

For Mac OS

[php]
python3 manage.py makemigrations
python3 manage.py migrate
[/php]

For Windows

[php]
python manage.py makemigrations
python manage.py migrate
[/php]

 

After these commands you are ready to see your login and signup pages. You need to run the server now with following command.

For Mac OS

[php]
python3 manage.py runserver
[/php]

For Windows

[php]
python manage.py runserver
[/php]

 

After that, browse the login page by going localhost:8000/accounts/login. You will see a login page with barely designed.

You can extend this Django all-auth signup system very easily. You can follow the official documentation of all-auth. Django all-auth documentation link.

Let me know in the comment section if you face any issue in setting up the Django all-auth.

 

1 thought on “How to create Django all-auth signup login system”

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top