Django中的密码重置没有reverseMatch错误?
Posted
技术标签:
【中文标题】Django中的密码重置没有reverseMatch错误?【英文标题】:No reverseMatch error in password reset in Django? 【发布时间】:2014-05-02 05:35:56 【问题描述】:我已经看到several posts
并尝试了所有建议的解决方案来解决此问题。但我仍然有以下错误。我正在使用Django 1.6
。
NoReverseMatch at /accounts/password/reset/Mw/3q6-5e4aba3a21e3b697aca2/
Reverse for 'password_reset_complete' with arguments '()' and keyword arguments '' not found. 0 pattern(s) tried: []
Request Method: GET
Request URL: http://127.0.0.1:8000/accounts/password/reset/Mw/3q6-5e4aba3a21e3b697aca2/
Django Version: 1.6.2
Exception Type: NoReverseMatch
Exception Value:
Reverse for 'password_reset_complete' with arguments '()' and keyword arguments '' not found. 0 pattern(s) tried: []
我尝试了两个不同的URLconfs
,都没有帮助。这是我尝试过的。
from django.conf.urls import include
from django.conf.urls import patterns
from django.conf.urls import url
from django.contrib.auth import views as auth_views
from django.core.urlresolvers import reverse_lazy
# urlpatterns = patterns('',
# url(r'^login/$',
# auth_views.login,
# 'template_name': 'registration/login.html',
# name='auth_login'),
# url(r'^logout/$',
# auth_views.logout,
# 'template_name': 'registration/logout.html',
# name='auth_logout'),
# url(r'^password/change/$',
# auth_views.password_change,
# 'post_change_redirect': reverse_lazy('auth_password_change_done'),
# name='auth_password_change'),
# url(r'^password/change/done/$',
# auth_views.password_change_done,
# name='auth_password_change_done'),
# url(r'^password/reset/$',
# auth_views.password_reset,
# 'post_reset_redirect': reverse_lazy('auth_password_reset_done'),
# name='auth_password_reset'),
# url(r'^password/reset/confirm/$',
# 'django.contrib.auth.views.password_reset_confirm',
# name='auth_password_reset_confirm'),
# # url(r'^password/reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$',
# # auth_views.password_reset_confirm,
# # name='auth_password_reset_confirm'),
# url(r'^password/reset/complete/$',
# auth_views.password_reset_complete,
# 'post_reset_redirect': reverse_lazy('auth_password_reset_complete'),
# name='auth_password_reset_complete'),
# url(r'^password/reset/done/$',
# auth_views.password_reset_done,
# name='auth_password_reset_done'),
# )
urlpatterns = patterns('',
url(r'^password/change/$',
auth_views.password_change,
name='auth_password_change'),
url(r'^password/change/done/$',
auth_views.password_change_done,
name='password_change_done'),
url(r'^password/reset/$',
auth_views.password_reset,
name='auth_password_reset'),
url(r'^password/reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]1,13-[0-9A-Za-z]1,20)/$',
auth_views.password_reset_confirm,
name='auth_password_reset_confirm'),
url(r'^password/reset/complete/$',
auth_views.password_reset_complete,
name='auth_password_reset_complete'),
url(r'^password/reset/done/$',
auth_views.password_reset_done,
name='password_reset_done'),
)
【问题讨论】:
【参考方案1】:您的代码正在寻找名称为 password_reset_complete
的 url,但您的 URLconf 包含一个名为 AUTH_password_reset_complete
的视图。删除auth_
,它应该可以工作。
【讨论】:
以上是关于Django中的密码重置没有reverseMatch错误?的主要内容,如果未能解决你的问题,请参考以下文章
在使用 Django 框架构建的博客 Web 应用程序中单击重置密码时,我没有收到密码重置电子邮件链接
在没有浏览器的情况下在 django 中触发密码重置电子邮件?
NoReverseMatch:在 Django 注册中的密码重置表单中?
NoReverseMatch at /accounts/password-reset/ 用于 Django 中的密码重置