升级Django和NoReverseMatch密码错误

我正在尝试将旧版本的Django 1.5升级到更新版本。 升级后,当我去密码重置页面,Django给我错误:

TypeError at / accounts / password / reset /

password_reset()得到了一个意外的关键字参数'post_change_redirect'

请求方法:GET TypeErrorRequest URL:http:// localhost:8000 / accounts / password / reset / Django版本:1.6.11异常类型:TypeError异常值:

password_reseteset()得到了一个意外的关键字参数'post_change_redirect'

异常位置:_wrapped_view中的/home/martin/Work/wisepress.com/virtualenv/local/lib/python2.7/site-packages/django/utils/decorators.py,第99行Python可执行文件:/ home / martin / Work / wisepress.com/virtualenv/bin/python Python版本:2.7.8

-

回溯:在get_response 112中的文件“/home/martin/Work/wisepress.com/virtualenv/local/lib/python2.7/site-packages/django/core/handlers/base.py”。response = wrapped_callback(request,* callback_args,** callback_kwargs)passwd_reset 109中的文件“/home/martin/Work/wisepress.com/eshopwisepress/wp_auth/views.py”。return password_reset(request,* args,** kwargs)File“/ home / martin / / home / lib / python2.7 / site-packages / django / utils / decorators.py“中的文件”/ workingpress / wisepress.com / virtualenv / local / lib / python2.7 / martin / Work / wisepress.com / virtualenv /local/lib/python2.7/site-packages/django/contrib/ auth / views.py“in password_reset 142. post_reset_redirect = reverse('password_reset_done')File”/ home / martin /Work/wisepress.com/virtualenv/local/lib/python2.7/site-packages/django/core/urlresolvers.py“,反向536. return iri_to_uri(resolver._reverse_with_prefix(view,prefix,* args,** kwargs ))文件“/home/martin/Work/wisepress.com/virtualenv/local/lib/python2。 7 / site-packages / django / core / urlresolvers.py“(lookup_view_s,args,kwargs,len(patterns),patterns))

异常类型:NoReverseMatch at / accounts / password / reset /异常值:未找到参数'()'和关键字参数'{}'的'password_reset_done'反向。 尝试了0个模式:[]

在urls.py中我有:

      url(r'^password/reset/done/$', 'django.contrib.auth.views.password_reset_done', name='passwd_reset_done'),
      url(r'^password/reset/confirm/(?P<uidb36>w+)/(?P<token>[dw-]+)/$', 'django.contrib.auth.views.password_reset_confirm_uidb36', name='passwd_reset_confirm'),
      url(r'^password/reset/completed/$', 'django.contrib.auth.views.password_reset_complete', name='passwd_reset_complete'),
      url(r'^password/reset/$', passwd_reset, {'template_name':'emailing/registration-activation/password_reset_email.html'}, name='password_reset'),

在views.py中我有:

from django.contrib.auth.views import password_reset

def passwd_reset(request, *args, **kwargs):
    kwargs['password_reset_form'] = PasswdResetForm
    kwargs['email_template_name'] = 'emailing/registration-activation/password_reset_email.html'
    kwargs['from_email'] = FROM_EMAIL
    return password_reset(request, *args, **kwargs)

在Django 1.5中,它工作正常,但在新版本中给我错误。 你知道任何人如何解决它? 谢谢

编辑:我改变了urls.py一些URL重置密码。 现在在那里:

    url(r'^password/reset/done/$', 'django.contrib.auth.views.password_reset_done', name='password_reset_done'),
    url(r'^password/reset/confirm/(?P<uidb64>[0-9A-Za-z_-]+)/(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm', name='password_reset_confirm'),
    url(r'^password/reset/completed/$', 'django.contrib.auth.views.password_reset_complete', name='password_reset_complete'),
    url(r'^password/reset/$', passwd_reset, {'template_name':'emailing/registration-activation/password_reset_email.html'}, name='password_reset'),

现在我有错误:

模板错误:在模板/home/martin/Work/wisepress.com/eshopwisepress/templates/emailing/registration-activation/password_reset_email.html中,第44行的错误

>反向'django.contrib.auth.views.password_reset_confirm'参数'()'和关键字参数'{u'uidb64':'',u'token':''}'找不到。 尝试1个模式:['accounts / password / reset / confirm /(?P w +)/(?P [ d w - ] +)/ $']

现在在线44是:

<a href="{{ protocol }}://{{ site_name }} {% url 'django.contrib.auth.views.password_reset_confirm' uidb64=uid token=token %} " target="_blank" style="color: #68b58e; text-decoration: none; font-style: italic;">Reset password</a><br/><br/>

-

回溯:在get_response 137中的文件“/home/martin/Work/wisepress.com/virtualenv/local/lib/python2.7/site-packages/django/core/handlers/base.py”。response = response.render()文件“/home/martin/Work/wisepress.com/virtualenv/local/lib/python2.7/site-packages/django/template/response.py”in render 105. self.content = self.rendered_content File“/ home / martin / Work / wisepress.com/virtualenv/local/lib/python2.7/site-packages/django/template/response.py“在rendered_content 82. content = template.render(context)File”/ home / martin / Work / wisepress.com / virtualenv / local / lib / python2.7 / site-packages / django / template / base.py“in render 140. return self._render(context)File”/ home / martin / Work / wisepress。 com / virtualenv / local / lib / python2.7 / site-packages / django / template / base.py“in _render 134. return self.nodelist.render(context)File”/home/martin/Work/wisepress.com/ virtualenv / local / lib / python2.7 / site-packages / django / template / base.py“in render 840. bit = self.render_node(node,context)File”/ home / marti n / Work / wisepress.com / virtualenv / local / lib / python2.7 / site-packages / django / template / debug.py“in render_node 78. return node.render(context)File”/ home / martin / Work / wisepress.com/virtualenv/local/lib/python2.7/site-packages/django/template/defaulttags.py“in render 447. six.reraise(* exc_info)File”/home/martin/Work/wisepress.com/ virtualenv / local / lib / python2.7 / site-packages / django / template / defaulttags.py“在渲染433. url = reverse(view_name,args = args,kwargs = kwargs,current_app = context.current_app)File”/ home /martin/Work/wisepress.com/virtualenv/local/lib/python2.7/site-packages/django/core/urlresolvers.py“反向536. return iri_to_uri(resolver._reverse_with_prefix(view,prefix,* args,* * kwargs))_reverse_with_prefix 456中的文件“/home/martin/Work/wisepress.com/virtualenv/local/lib/python2.7/site-packages/django/core/urlresolvers.py”。(lookup_view_s,args,kwargs, len(图案),图案))

异常类型:NoReverseMatch at / accounts / password / reset /异常值:为'django.contrib.auth.views.password_reset_confirm'反转参数'()'和关键字参数'{u'uidb64':'',u'token ': ''}' 未找到。 尝试1个模式:['accounts / password / reset / confirm /(?P w +)/(?P [ d w - ] +)/ $']


在您的password_reset url模式中, template_name不应与您的email_template_name相同。 template_name是向用户显示密码重置表单的模板。

链接地址: http://www.djcxy.com/p/55911.html

上一篇: Upgrade Django and NoReverseMatch password Error

下一篇: matching query does not exist