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 Monday, May 25, 2026 at 3:50 AM
#fullstack development, #macOS, #default django authentication system, #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
- Conclusion
- Related Resources
- Related Posts
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 our accounts/urls.py file:
urlpatterns = [ path("accounts/", include("django.contrib.auth.urls")), ]
Our 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 inclusion 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 our 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 above, 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 sign in page on the login page.
Conclusion
In this section, I placed the default Django authentication system related templates into a new directory called registration inside the templates directory, I moved the associated URLs into accounts/urls.oy, and added the associated default url pattern to django_boards/urls.py. This helped 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