Django userena错误反向' password_reset_done'参数'()'和关键字参数' {}'未找到。尝试过0种模式:[]

时间:2014-12-17 09:51:12

标签: python django

我正在使用Django Userena并且在密码重置部分我每次点击密码重置链接时都会收到以下错误。我正在使用Django 1.6。我发现了几个关于密码的问题重置问题,解决我的问题没有任何成果。

错误

NoReverseMatch at /accounts/password/reset/
Reverse for 'password_reset_done' with arguments '()' and keyword arguments '{}' not      found. 0 pattern(s) tried: []
Request Method: GET
Request URL:    http://med.finder-lbs.com/accounts/password/reset/
Django Version: 1.6.1
Exception Type: NoReverseMatch
Exception Value:    
Reverse for 'password_reset_done' with arguments '()' and keyword arguments '{}' not    found. 0 pattern(s) tried: []

urls.py

from django.conf.urls import *
from django.views.generic.base import TemplateView
from django.contrib.auth import views as auth_views
from django.contrib.auth.decorators import login_required

from userena import views as userena_views
from userena import settings as userena_settings

# Reset password
url(r'^password/reset/$',
   auth_views.password_reset,
   {'template_name': 'userena/password_reset_form.html',
    'email_template_name': 'userena/emails/password_reset_message.txt',
    'extra_context': {'without_usernames': userena_settings.USERENA_WITHOUT_USERNAMES}
    },
   name='userena_password_reset'),
url(r'^password/reset/done/$',
   auth_views.password_reset_done,
   {'template_name': 'userena/password_reset_done.html'},
   name='userena_password_reset_done'),
url(r'^password/reset/confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$',
   auth_views.password_reset_confirm,
   {'template_name': 'userena/password_reset_confirm_form.html'},
   name='userena_password_reset_confirm'),

url(r'^password/reset/confirm/complete/$',
   auth_views.password_reset_complete,
   {'template_name': 'userena/password_reset_complete.html'}),

这是模板中反向发生的部分,

<p class="forgot-password"><a href="{% url 'userena_password_reset' %}" title="{% trans 'Forgot your password?' %}">{% trans "Forgot your password?" %}</a></p>

1 个答案:

答案 0 :(得分:3)

这是因为Django的内置password_reset函数正在调用reverse('password_reset_done')。您可以看到代码here

您要做的是传递您希望post_reset_redirect重定向到的参数password_reset中的网址名称。