我正在使用django默認密碼重置功能。我通過電子郵件獲得設置新密碼電子郵件鏈接。頁面沒有找到(404)錯誤,如果重置密碼電子郵件鏈接是錯誤的Django
如果網址是正確的,那就好了。現在,如果我把一個錯誤的或無效的鏈接,然後我得到的,
The current URL, account/reset/NTQ/4ox-7f135b9b74e7a4aa909fdd/, didn't match any of these.
賬戶/ urls.py -
url(r'^password_reset/$', auth_views.password_reset, name='password_reset'),
url(r'^password_reset/done/$', auth_views.password_reset_done, name='password_reset_done'),
url(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
auth_views.password_reset_confirm, name='password_reset_confirm'),
#url(r'^reset/',auth_views.password_reset_confirm, name='empty_password_reset_confirm'),
url(r'^reset/done/$', auth_views.password_reset_complete, name='password_reset_complete'),
模板password_reset_confirm.html -
{% extends 'base.html' %}
{% block content %}
{% if validlink %}
<h3>Change password</h3>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Change password</button>
</form>
{% else %}
<p>
The password reset link was invalid, possibly because it has already been used.
Please request a new password reset.
</p>
{% endif %}
{% endblock %}
我試着用 -
url(r'^reset/',auth_views.password_reset_confirm, name='empty_password_reset_confirm')
但是在那種情況下,我是越來越AssertionError at /account/reset/NTQ/4ox-7f135b9b74e7a4aa909fdd/
任何幫助,高度讚賞。
您已經描述了當前的預期行爲。但是你想要什麼呢? –
如果url是錯誤的,它不應該顯示404錯誤。相反,它應該顯示'password_reset_confirm.html'文件的'else'部分。 –