我正在使用django userena并收到错误。提交密码重置的电子邮件地址后,我收到了通过重置确认邮件。邮件正文是这样的
You're receiving this e-mail because you requested a password reset
for your user account at example.example.com.
Please go to the following page and choose a new password:
http://example.example.com/accounts/password/reset/confirm/Mg-3xm-add2c70e92d3694c5043/
Your username, in case you've forgotten: ****
Thanks for using our site!
Sincerely,
example.example.com
但点击链接以选择新密码后,我收到以下错误
NoReverseMatch at /accounts/password/reset/confirm/Mg-3xm-add2c70e92d3694c5043/
Reverse for 'password_reset_complete' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
Request Method: GET
Request URL: http://med.finder-lbs.com/accounts/password/reset/confirm/Mg-3xm- add2c70e92d3694c5043/
Django Version: 1.6.1
Exception Type: NoReverseMatch
Exception Value:
Reverse for 'password_reset_complete' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
urls.py
url(r'^resetpassword/passwordsent/$', 'django.contrib.auth.views.password_reset_done', name='password_reset_done'),
url(r'^password/reset/$',
auth_views.password_reset,
{'template_name': 'userena/password_reset_form.html',
'email_template_name': 'userena/emails/password_reset_message.txt',
'extra_context': {'without_usernames': userena_settings.USERENA_WITHOUT_USERNAMES}
},
name='userena_password_reset'),
url(r'^password/reset/done/$',
auth_views.password_reset_done,
{'template_name': 'userena/password_reset_done.html'},
name='userena_password_reset_done'),
url(r'^user/password/reset/confirm/$',
'django.contrib.auth.views.password_reset_confirm'),
url(r'^password/reset/confirm/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$',
auth_views.password_reset_confirm,
{'template_name': 'userena/password_reset_confirm_form.html'},
name='userena_password_reset_confirm'),
url(r'^password/reset/confirm/complete/$',
auth_views.password_reset_complete,
{'template_name': 'userena/password_reset_complete.html'}),
password_reset_message.txt
{% load i18n %}{% autoescape off %}{% load url from future %}
{% blocktrans %}You're receiving this e-mail because you,requested a password reset
for your user account at {{ site_name }}{% endblocktrans %}.
{% trans "Please go to the following page and choose a new password:" %}
{% block reset_link %}
{{ protocol }}://{{ domain }}{% url 'userena_password_reset_confirm' uidb64=uid token=token %}
{% endblock %}
{% if not without_usernames %}{% blocktrans with user.username as username %}
Your username, in case you've forgotten: {{ username }}
{% endblocktrans %}
{% endif %}
{% trans "Thanks for using our site!" %}
{% trans "Sincerely" %},
{{ site_name }}
{% endautoescape %}
我很确定这里遗漏的东西,但我无法弄明白。我正在使用django 1.6
答案 0 :(得分:0)
# urls.py
url(r'^password/reset/confirm/complete/$',
auth_views.password_reset_complete,
{'template_name': 'userena/password_reset_complete.html'},
name='password_reset_complete') # must be named for reverse to work
命名url应解决NoReverseMatch错误。
但是,听起来您可能还有另一个问题,因为您在单击重置链接后立即将此错误描述为正在发生,这意味着password_reset_confirm
视图正在尝试将用户重定向到{{1}立即 - 不是在他们选择了新密码之后。