How to create a fullstack application using Django and Python Part 30
Social Share:
Friday, November 8, 2024 at 11:20 AM | 2 min read
Last modified on Thursday, July 16, 2026 at 12:29 PM
#fullstack development, #macOS, #django default authentication, #django, #python3, #series

Photo by Andrea Piacquadio on pexels.com
Important Note: Before committing anything to Git or pushing anything to remote, please visit How to create a fullstack application using Django and Python Part 4 where I discuss how to add the python-dotenv package to the Django site and why it is crucial to do it. This article assumes you have a working knowledge of Git.
Table of Contents
- Re-organizing the default Django authentication system related templates and URLs
- Code associated with this post
- Conclusion
- Related Resources
- Related Posts
Update (July 2026): This walkthrough was written against Django 5.1, which reached full end-of-life in December 2025 and is no longer receiving security patches. Run python -m django --version to check which version you have.
I wrote this series as a live process, so sometimes it might seem confusing, but it all works out in the end.
Re-organizing the default Django authentication system related templates and URLs
According to research I conducted after a couple of failed deployments on Heroku, I found that when using the default Django authentication system, the following URL pattern should be added in my accounts/urls.py file:
urlpatterns = [ path("accounts/", include("django.contrib.auth.urls")), ]
My accounts/urls.py file should now look like the following:
from django.urls import path from .views import profile, profile_detail, ProfileListView, UserUpdateView, signup from django.contrib.auth import views as auth_views urlpatterns = [ path('account/', UserUpdateView.as_view(), name='my_account'), path("profile/", profile, name="users-profile"), path('profile-detail/<int:pk>/', profile_detail, name='profile'), path("profiles/", ProfileListView.as_view(), name="users-profile-list"), path("signup/", signup, name="signup"), path( "login/", auth_views.LoginView.as_view(), name="login" ), path("logout/", auth_views.LogoutView.as_view(), name="logout"), path( "password_reset/", auth_views.PasswordResetView.as_view(), name="password_reset", ), path( "password_reset/done/", auth_views.PasswordResetDoneView.as_view(), name="password_reset_done", ), path( "reset/<uidb64>/<token>/", auth_views.PasswordResetConfirmView.as_view(), name="password_reset_confirm", ), path( "reset/done/", auth_views.PasswordResetCompleteView.as_view(), name="password_reset_complete", ), path( "password_change/", auth_views.PasswordChangeView.as_view(), name="password_change", ), path( "password_change/done/", auth_views.PasswordChangeDoneView.as_view(), name="password_change_done", ), ]
Adding these default registration/password reset URLs results in the generation of the following URL patterns:
accounts/login/ [name='login'] accounts/logout/ [name='logout'] accounts/password_change/ [name='password_change'] accounts/password_change/done/ [name='password_change_done'] accounts/password_reset/ [name='password_reset'] accounts/password_reset/done/ [name='password_reset_done'] accounts/reset/<uidb64>/<token>/ [name='password_reset_confirm'] accounts/reset/done/ [name='password_reset_complete']
According to the Django authentication system documentation, the associated templates should reside in a directory called registration. Now my templates directory should look like the following:
- templates/ ... - registration/ - login.html - password_change_done.html - password_change.html - password_reset_complete.html - password_reset_confirm.html - password_reset_done.html - password_reset_email.html - password_reset_subject.txt - password_reset.html - signup.html ...
Since the signup.html template is not included in the list of URL patterns, when a new visitor lands on the site, they see the link to the sign in (login) page and not the signup page. However, there is a link to the signup page on the login page.
Code associated with this post
To view the code associated with this post, please visit a35acbd.
Conclusion
In this section, I place the default Django authentication system related templates into a new directory called registration inside the templates directory, I move the associated URLs into accounts/urls.py, and add the associated default url pattern to django_boards/urls.py. This helps ensure that django-boards deployment to Heroku would be successful.
Related Resources
- Django Boards repository on GitHub
- How to create a fullstack application using Django and Python Part 16: mariadcampbell.com
- Using the Django authentication system: Django documentation