密码重置功能Django的NoReverseMatch错误 [英] NoReverseMatch error in password reset functionality django

查看:86
本文介绍了密码重置功能Django的NoReverseMatch错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Django中实现密码重置功能,下面是我的代码

I am trying to implement password reset funcitonality in django and below are my codes

urls.py

urlpatterns = patterns('',
    url(r'^signup/$', 'accounts.views.signup', name="signup_email"),
    url(r'^user/password/reset/$', 'django.contrib.auth.views.password_reset', {'template_name':'accounts/forgot_password.html',\
                               'post_reset_redirect' : '/user/password/reset/done/'}, name="reset_password"),
    url(r'^user/password/reset/done/$', 'django.contrib.auth.views.password_reset_done'),

forgot_password.html

     <form accept-charset="UTF-8" action="{% url 'reset_password' %}" class="reset_pass" id="reset_pass" method="post">
            {% csrf_token %}
            <div class="control-group">
                <label class="control-label" for="user_email" style="font-size: 18px; color: #474747">Email</label>
                <div class="controls">
                    <input class="" id="id_email" name="email" type="text" value="">

                </div>
            </div>
            <div class="control-group">
                <div class="controls">
                    <button type="submit" value="reset_password" class="btn btn-primary">Send me reset password</button>
                </div>
            </div>
       </form>

因此,当我们转到URL user/password/reset/时,将显示forgot_password.html,当我输入电子邮件并提交表格时,出现以下错误

so when we go to the url user/password/reset/ a forgot_password.html is displaying, and when i entered the email and submitted the form i am getting the below errors

模板渲染期间发生错误

In template /home/user/proj/virtualenvironment/apps/pro_utils/accounts/templates/registration/password_reset_email.html, error at line 7

即使我使用内置视图,任何人都可以让我知道为什么它抱怨NoReversemtach吗?

Can any one please let me know why it is complaining NoReversemtach even though i am using builtin views ?

推荐答案

您需要按如下所示在urls.py中添加该url + view

You need to add that url+view in urls.py as below

url(r'^user/password/reset/confirm/$', 
             'django.contrib.auth.views.password_reset_confirm'),

它提供了一个用于输入新密码的表格.

It presents a form for entering a new password.

您可能还必须添加它

url(r'^user/password/reset/complete/$', 
             'django.contrib.auth.views.password_reset_complete'),

这篇关于密码重置功能Django的NoReverseMatch错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆