Q:

code working fine, just problem is on successful operation, successful message not working

This code is working Fine Updating User password the only problem am facing that on successful operation. Success msg is not printing on page
views.py
def change_password(request):
    if request.method == 'POST':
        form = PasswordChangeForm(request.user, request.POST)
        if form.is_valid():
            user = form.save()
            update_session_auth_hash(request, user)  # Important!
            messages.success(request, 'Your password was successfully updated!')
            return redirect('change_password')
        else:
            messages.error(request, 'Please correct the error below.')
    else:
        form = PasswordChangeForm(request.user)
    return render(request, 'accounts/change_password.html', {
        'form': form
    })

change_password.html
{% extends 'accounts/base.html' %}

{% block content %}
<!-- {{messages}} -->

{{ pwd_updated }}
<form method="post">
  {% csrf_token %}
  {{ form }}
  <button type="submit">Save changes</button>
</form>

{% endblock %}

i tried this but this is also not working:
        print(messages.success(request, 'Your password was successfully updated!'))

also tried this:
    pwd_updated = messages.success(request, 'Your password was successfully updated!')
    return redirect('change_password',{'pwd_updated':pwd_updated})

& fetching it on my html.
but not working.

A:

In change_password.html try to use this below code:
{% block content %}
    {% for message in messages %}
        {{ message }}
    {% endfor %}

    ...

{% endblock %}

That should help.

