简体   繁体   中英

Django NoReverseMatch at accounts/password_reset/

This seems like a common problem people are running into, but I can't figure it out for the life of me. I've set up a URL:

from django.conf.urls import url
from . import views
from django.contrib.auth import views as auth_views

urlpatterns = [
    url(r'^login/$', views.login_view, name='login'),
    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'^auth/$', views.login_auth, name='login_auth'),
    url(r'^register/$', views.register_user, name='register'),
    url(r'^logout/$', views.logout_user, name='logout'),
]

I try to link to the password_reset URL:

<a href="/accounts/password_reset/">Forgot Password?</a>

But it gives me the following error:

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

This seems like a really simple bit of code, but it doesn't work. I can successfully call password_reset_done using this exact method, but for some reason it doesn't work with password_reset .

password_reset行应如下所示:

url(r'^password_reset/$', auth_views.password_reset, {'post_reset_redirect' : '/accounts/password_reset_done/'}, name='password_reset'),

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM