帐户/password_reset/上的Django NoReverseMatch [英] Django NoReverseMatch at accounts/password_reset/

查看:33
本文介绍了帐户/password_reset/上的Django NoReverseMatch的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这似乎是人们遇到的常见问题,但我无法终生解决.我已经设置了一个网址:

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'),
]

我尝试链接到 password_reset URL:

I try to link to the password_reset URL:

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

但这给了我以下错误:

在/accounts/password_reset/下的NoReverseMatch/找不到带有参数'()'和关键字参数'{}'的'password_reset_done'.尝试了0个模式:[]

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

这似乎是一段非常简单的代码,但它不起作用.我可以使用此确切方法成功调用 password_reset_done ,但是由于某些原因,它不能与 password_reset 一起使用.

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'),

这篇关于帐户/password_reset/上的Django NoReverseMatch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆