This is a very quick tip about how to create a change password view using the built-in PasswordChangeForm.
For that matter, using a function-based view is easier, because the PasswordChangeForm is slightly different.
It does not inherit from ModelForm and it takes an user argument in its constructor.
The example below is a functional code to change the password for the authenticated user.
views.py
The messages.success() and messages.error() are optional, but it is a good idea to keep your user aware about what
is going on in the application.
Now an important bit is to call update_session_auth_hash() after you save the form. Otherwise the user’s auth session
will be invalidated and she/he will have to log in again.