Django的:内置密码重置意见 [英] Django: built-in password reset views

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

问题描述

我下面的文件,当我在页面上点击重新启动我的密码,我得到一个错误NoReverseMatch

I am following the documentation and I am getting a NoReverseMatch error when I click on the page to restart my password.

在NoReverseMatch / resetpassword /
反向password_reset_done'与参数()和关键字参数'{}'未找到。 0模式(S)尝试:[]

NoReverseMatch at /resetpassword/ Reverse for 'password_reset_done' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

urls.py:

(r'^resetpassword/passwordsent/$', 'django.contrib.auth.views.password_reset_done'),
(r'^resetpassword/$', 'django.contrib.auth.views.password_reset', name="reset_password"),
(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'),

下面是code,在我的base.html文件模板调用此网址:

Here is the code that calls this url in my base.html template:

<a href="{% url 'reset_password' %}">Reset Password</a>

我一直在这工作了几个小时。 (我是初学者!)任何帮助将大大pciated AP $ P $,谢谢!

I have been working at this for hours. (I'm a beginner!) Any help would be much appreciated, thanks!

推荐答案

URL名称添加到条目在 urls.py password_reset_done

Add the url name to the entry in your urls.py for password_reset_done:

(r'^resetpassword/passwordsent/$', 'django.contrib.auth.views.password_reset_done', name='password_reset_done'),

在内部, password_reset 视图使用反向('password_reset_done')查找到哪里后,发送用户重置密码。 逆转可以接受字符串重函数名presentation,但它需要匹配你的模式中使用的形式 - 在这种情况下,就不能匹配,因为完整路径中的图案,但不能在反向调用中指定。你可以导入从模块的意见,并在该模式只使用他们的名字或你的模式使用preFIX如果你愿意preFER,超过了名称参数。

Internally, the password_reset view uses reverse('password_reset_done') to look up where to send the user after resetting the password. reverse can take a string representation of a function name, but it needs to match the form used in your patterns - in this case, it can't match because the full path is specified in your pattern but not in the reverse call. You could import the views from the module and use just their names in the pattern or use a prefix in your patterns if you'd prefer that over the name argument.

<一个href=\"https://docs.djangoproject.com/en/dev/ref/urlresolvers/#django.core.urlresolvers.reverse\">https://docs.djangoproject.com/en/dev/ref/urlresolvers/#django.core.urlresolvers.reverse有关详细信息,逆转

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

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