您的位置:首页 > 编程语言 > Go语言

六 Django 1.5.4 Password Reset

2013-11-05 12:12 295 查看

一.urls.py

(r'^resetpassword/passwordsent/$','django.contrib.auth.views.password_reset_done'),
  (r'^resetpassword/$','django.contrib.auth.views.password_reset'),
  (r'^reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$','django.contrib.auth.views.password_reset_confirm'),
  (r'^reset/done/$','django.contrib.auth.views.password_reset_complete'),

二.执行

cd video1/templates
cp -r /root/mysiteenv/lib/python2.7/site-packages/django/contrib/admin/templates/registration ./


templates/login.html

{% extends "base.html" %}
{% block content %}
<form action="" method="post">{% csrf_token %}
    {% if form.errors %}
    <p> Please correct the following fields: </p>
    {% endif %}
    <div class="register_div">
        {% if form.username.errors %} <p class="error"> {{ form.username.errors }} </p> {% endif %}
        <p><label for="username" {% if form.username.errors %} class="error" {% endif %}>Username:</label></p>
        <p>{{ form.username }}</p>
    </div>
    <div class="register_div">
        {% if form.password.errors %} <p class="error"> {{ form.password.errors }} </p> {% endif %}
        <p><label for="password" {% if form.password.errors %} class="error" {% endif %}>Password:</label></p>
        <p>{{ form.password}}</p>
    </div>
    <p><input type="submit" alt="register"></p>
</form>
<p>Forgot your password?<a href="/resetpassword/"> Reset it!  </a> </p>
{% endblock %}




registration/password_reset_form.html

将所有的{% extends "admin/base_site.html" %} 改为{% extends "base.html" %}

类似的如registration/password_reset_confirm.html

registration/password_reset_complete.html

registration/password_reset_done.html

...templates/registration目录下的所有文件

{% extends "base.html" %}
 {% load i18n %}
 {% load url from future %}

 {% block breadcrumbs %}
 <div class="breadcrumbs">
 <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
 › {% trans 'Password reset' %}
 </div>
 {% endblock %}

 {% block title %}{% trans "Password reset" %}{% endblock %}

 {% block content %}

 <h1>{% trans "Password reset" %}</h1>

 <p>{% trans "Forgotten your password? Enter your e-mail address below, and we'll e-mail instructions for setting a new one." %}</p>

 <form action="" method="post">{% csrf_token %}
 {{ form.email.errors }}
 <p><label for="id_email">{% trans 'E-mail address:' %}</label> {{ form.email }} <input type="submit" value="{% trans 'Reset my password' %}" /></p>
 </form>

 {% endblock %}






修改domain name 用来在发送修改邮件地址时出现的域名

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: