Basically, all you need to have django.contrib.auth in your INSTALLED_APPS and an email service properly configurated (for production). In this tutorial, we are going to use console email backend which prints email in console(terminal/command line) instead of sending an email.
How to Create Change Password in Django
Implementing a built-in Change Password in Django is very easy. Django provides authentication and authorization. For Changing Password you need to get authenticated first.
In your urls.py, we need to import PasswordChangeView from Django Auth. By default, Django PasswordChangeView will render template registration/change_password.html. But we need some customization and we’ll tell PasswordChangeView to render a template from commons/change-password.html. success_url is also a way to redirect a user after changing the password successfully.
urls.py
from django.contrib import adminfrom django.urls import path, includefrom django.contrib.auth import views as auth_viewsurlpatterns =[...# Change Passwordpath('change-password/', auth_views.PasswordChangeView.as_view(template_name='commons/change-password.html',success_url='/'),name='change_password'),]