Changing password in Django

Add this to your urls.py:


url(r'^accounts/change-password/', 'django.contrib.auth.views.password_change',
    {'post_change_redirect' : '/accounts/password-changed/'}),
url(r'^accounts/password-changed/', 'django.contrib.auth.views.password_change_done'),

Just edit the links above. Then in you templates folder, create new folder and name it  registration . . Then create this html file below:


password_change_form.html
{% extends "edit_profile.html" %}
{% block head_title %}Change Password{% endblock %}
{% block content %}
<div class="jumbotron" style="width: 940px; margin: 80px auto; border-radius: 5px;">
    <form method="post" action=".">

         {% if next %}
                <input type="hidden" name="next" value="{{ next }}" />
            {% endif %}
        {{form.as_p}}
        <input type="submit" value="Change" class="btn btn-primary btn-lg" />
        {% csrf_token %}
    </form>
</div>
{% endblock %}

password_change_done.html
{% extends "edit_profile.html" %}
{% block head_title %}Password Change Successful{% endblock %}
{% block content %}
<div class="jumbotron" style="border-radius: 5px; margin: 80px auto; width: 940px;">
<div class="alert alert-success" style="padding: 5px;">
Your password has been changed successfully. Please <a href="https://www.blogger.com/accounts/logout/">re-login</a> with your new credentials
        or go back to the <a href="https://www.blogger.com/accounts/loggedin/">main page</a>.
    </div>
</div>
{% endblock %}

That's it! It should work fine. Here's what it looks like using Bootstrap.


Comments

Popular posts from this blog

Auto-calculate your Splinterlands Assets/Income

Creating a Simple Button for Demo

Splinterlands: Water Deck for Beginners