NoReverseMatch:反向''django.contrib.auth.views.password_reset_confirm''

时间:2017-05-24 12:59:50

标签: python django django-authentication

我正在使用Django 1.5.12并且我收到此错误并且不知道如何解决它。其他'NoReverseMatch'帖子对我没有帮助

  

NoReverseMatch:反向'django.contrib.auth.views.password_reset_confirm',带参数'()'和关键字参数'{u'uidb36':u'mg',u'token':u'4mb-cc37d48' '找不到。

url.py

urlpatterns = patterns('',
(r'^my-account/password-reset/$', 
  'django.contrib.auth.views.password_reset', {
    'post_reset_redirect': '/my-account/password-reset/done/',
    'template_name': 'password_reset/password_reset_form.html',
    'email_template_name': 'password_reset/password_reset_email.html'
  }),
(r'^my-account/password-reset/done/$', 
  'django.contrib.auth.views.password_reset_done', {
    'template_name': 'password_reset/password_reset_done.html'
  }),
(r'^my-account/password-reset/((?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+))/$', 
  'django.contrib.auth.views.password_reset_confirm', {
    'post_reset_redirect': '/my-account/password-reset/complete/',
    'template_name': 'password_reset/password_reset_confirm.html'
  })

password_reset_email.html

{% autoescape off %}
You're receiving this e-mail because you requested a password reset for your 
user account.

Please go to the following page and choose a new password:
{% block reset_link %}
{{ protocol }}://{{ domain }}{% url 
'django.contrib.auth.views.password_reset_confirm' uidb36=uid token=token %}
{% endblock %}

关于如何解决这个问题的任何想法?

1 个答案:

答案 0 :(得分:0)

尝试删除(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)周围的外括号:

(r'^my-account/password-reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$', 
 'django.contrib.auth.views.password_reset_confirm', {
     'post_reset_redirect': '/my-account/password-reset/complete/',
     'template_name': 'password_reset/password_reset_confirm.html'
})