Django authentication and social-sign on with django-allauth

How to use django-allauth URLs in our project

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

djangocourse/settings.py
--- 
+++ 
@@ -135,7 +135,7 @@


 LOGIN_REDIRECT_URL = "home"
-LOGOUT_REDIRECT_URL = "login"
+LOGOUT_REDIRECT_URL = "account_login"

 # Internationalization
 # https://docs.djangoproject.com/en/5.1/topics/i18n/
djangocourse/urls.py
--- 
+++ 
@@ -16,10 +16,12 @@
 """
 from django.contrib import admin
 from django.urls import path, include
+from django.views.generic.base import RedirectView

 urlpatterns = [
     path("admin/", admin.site.urls),
     path("articles/", include("app.urls")),
-    path("accounts/", include("django.contrib.auth.urls")),
+    path("accounts/", include("allauth.urls")),
+    path("", RedirectView.as_view(pattern_name="home")),
     path("__debug__/", include("debug_toolbar.urls"))
 ]
templates/app/base.html
--- 
+++ 
@@ -11,12 +11,12 @@
       <li><a href="{% url 'home' %}">Articles</a></li>
       <li>
         {% if user.is_authenticated %}
-          <form method="POST" action="{% url 'logout' %}">
+          <form method="POST" action="{% url 'account_logout' %}">
             {% csrf_token %}
             <button type="submit">Log out</button>
           </form>
         {% else %}
-          <a href="{% url 'login' %}">Log in</a>
+          <a href="{% url 'account_login' %}">Log in</a>
         {% endif %}
       </li>
     </ul>