As a new bee I faced difficulties while dealing with this error which comes when we update password using custom Template, I spend quite good time to come over this issue, did R&d but didn’t get right answer… somehow after a lot of R&d I managed to fix it… I want my post be helpful for someone who face same.
from django.contrib.auth import update_session_auth_hash
custom_user = CustomUser.objects.get(id=request.user.id)
if password != None and password !=’’:
update_session_auth_hash(request, custom_user) #problem solver line.
messages.success(request, “Your profile updated successfully !”)