Django authentication and social-sign on with django-allauth

How to set up django-allauth

Want more?

This lesson for enrolled students only. Join the course to unlock it!

You can see the code changes implemented in this lecture below.

If you have purchased the course in a different platform, you still have access to the code changes per lecture here on Teclado. The lecture video and lecture notes remain locked.
Join course for $15

Modified files

pyproject.toml
--- 
+++ 
@@ -8,6 +8,7 @@
 [tool.poetry.dependencies]
 python = "^3.12"
 django = "^5.1.3"
+django-allauth = {extras = ["socialaccount"], version = "^65.2.0"}


 [tool.poetry.group.dev.dependencies]
djangocourse/settings.py
--- 
+++ 
@@ -27,11 +27,14 @@

 ALLOWED_HOSTS = []

+AUTHENTICATION_BACKENDS = [
+    "allauth.account.auth_backends.AuthenticationBackend"
+]
+

 # Application definition

-INSTALLED_APPS = [
-    "app.apps.AppConfig",
+DJANGO_APPS = [
     'django.contrib.admin',
     'django.contrib.auth',
     'django.contrib.contenttypes',
@@ -39,6 +42,17 @@
     'django.contrib.messages',
     'django.contrib.staticfiles',
 ]
+
+THIRD_PARTY_APPS = [
+    "allauth",
+    "allauth.account",
+]
+
+PROJECT_APPS = [
+    "app.apps.AppConfig",
+]
+
+INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + PROJECT_APPS

 MIDDLEWARE = [
     'django.middleware.security.SecurityMiddleware',
@@ -48,6 +62,7 @@
     'django.contrib.auth.middleware.AuthenticationMiddleware',
     'django.contrib.messages.middleware.MessageMiddleware',
     'django.middleware.clickjacking.XFrameOptionsMiddleware',
+    "allauth.account.middleware.AccountMiddleware",
 ]

 if DEBUG: