DEFAULT AUTH URLs in DJANGO (easy way to use in-built auth urls and in-built LoginView)

Опубликовано: 14 Август 2026
на канале: Developer Bites
140
1

Django provides some in-built URLs for authentication and these are found in the package django.contrib.auth.urls. To use these URLs, in the default urls.py file, add the following line:

path('accounts/', include('django.contrib.auth.urls')),

The auth URLs are:

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']

You need to create additional templates in the folder templates/registration to use these URL functionality properly as already shown in the video.

To define page to redirect after login, you can use the following constant in the settings.py file:

LOGIN_REDIRECT_URL = 'profile'

To reduce the code for login view, you can make use the in-built LoginView auth class for more versatile login functionality.

django.contrib.auth.views import LoginView