Gotz84
Gotz84

Reputation: 45

Django password is not changed

I don't know what I'm doing wrong, but when I try to change the password it doesn't change it and it doesn't give any errors.

urls.py

from django.contrib.auth.views import logout,password_change,password_change_done
...
url(r'^change_password/?$',password_change, name='password_change'),
url(r'^password_changed/?$',password_change_done, name='password_change_done'),
url(r'^logout/?$',logout, name='logout'),

password_change_form.html

<form action="{% url 'password_change_done' %}" method="post">
    {% csrf_token %}
    {% bootstrap_form form layout="inline" form_group_class="form-group col-md-6" %}
    <div class="clearfix"></div>
    {% buttons %}
        <button type="submit" name="save" class="btn btn-primary">{% bootstrap_icon "plus" %} {% trans 'save' %}</button>
    {% endbuttons %}
</form>

When I click on save, it shows the template "password_change_done.html" but the password hasn't been changed. However, there are no errors in the console and I don't know what fails.

Thank you all

Upvotes: 0

Views: 111

Answers (1)

Moses Koledoye
Moses Koledoye

Reputation: 78556

The form action should be password_change not password_change_done:

<form action="{% url 'password_change' %}" method="post">

Django will automatically do the redirect to password_change_done for you once the password change is successful.

Upvotes: 2

Related Questions