Django:NoReverseMatch - >反向找不到'password_reset_done'。 'password_reset_done'不是有效的视图函数或模式名称

时间:2018-05-03 18:57:25

标签: python django django-views python-3.5

访问http://localhost:8000/reset-password/时出现以下错误:

/ reset-password /

的NoReverseMatch

未找到'password_reset_done'的反向。 'password_reset_done'不是有效的视图函数或模式名称。

但是,如果我访问http://localhost:8000/reset-password/done/,则表示没有错误。

from django.conf.urls import url
from account import views
from django.contrib.auth.views import (
    login,
    logout,
    password_reset,
    password_reset_done,
    password_reset_confirm,
    password_reset_complete,
)


urlpatterns = [
    url(r'^register/$', views.register_view, name='register'),
    url(r'^login/$', login, {'template_name': 'account/login.html'}, name='login'),
    url(r'^logout/$', logout, {'template_name': 'home.html',
        'next_page': '/login'}, name='logout'),
    url(r'^profile/$', views.view_profile, name='profile'),
    url(r'^profile/edit/$', views.edit_profile, name='edit_profile'),
    url(r'^profile/change-password/$', views.change_password, name='change_password'),
    url(r'^reset-password/$', password_reset, name='reset_password'),
    url(r'^reset-password/done/$', password_reset_done, name='reset_password_done'),
    url(r'^reset-password/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
        password_reset_confirm, name='reset_password_confirm'),
    url(r'^reset-password/complete/$', password_reset_complete, name='reset_password_complete'),

]

请帮我解决这个错误。我正在使用django vesion 2.0.2。

提前致谢。

1 个答案:

答案 0 :(得分:0)

这里的拼写错误:您没有所谓的url_name = password_reset_done,您有reset_password_done

 url(r'^reset-password/done/$', password_reset_done, name='reset_password_done'),