Python 升级Django和NoReverseMatch密码错误
我正在尝试将旧版本Django 1.5升级到新版本。 升级后,当我进入密码重置页面时,Django告诉我错误: 在/accounts/password/reset/ password_reset()获得意外的关键字参数“post_change_redirect” 请求方法:获取 TypeErrorRequestURL: Django版本:1.6.11 异常类型:TypeError 异常值: password_ResetSet()得到一个意外的关键字参数“post_change_redirect” 异常位置:/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_响应中的文件“/home/martin/Work/wisepress.com/virtualenv/local/lib/python2.7/site packages/django/core/handlers/base.py” 112响应=包装的回调(请求,*回调参数,**回调参数) passwd\u reset中的文件“/home/martin/Work/wisepress.com/eshopwisepress/wp\u auth/views.py” 109返回密码\u重置(请求,*args,**kwargs) 视图中的文件“/home/martin/Work/wisepress.com/virtualenv/local/lib/python2.7/site packages/django/utils/decorators.py” 99响应=查看功能(请求,*args,**kwargs) 密码重置中的文件“/home/martin/Work/wisepress.com/virtualenv/local/lib/python2.7/site packages/django/contrib/auth/views.py” 142post\u reset\u redirect=reverse('password\u reset\u done') 文件“/home/martin/Work/wisepress.com/virtualenv/local/lib/python2.7/site packages/django/core/urlresolvers.py”的格式相反 536将iri_返回到_uri(解析器。_使用_前缀反向_(视图,前缀,*args,**kwargs)) 文件“/home/martin/Work/wisepress.com/virtualenv/local/lib/python2.7/site packages/django/core/urlresolvers.py”位于带前缀的 456(查找\视图\参数、kwargs、len(模式)、模式) 异常类型:NoReverseMatch at/accounts/password/reset/ 异常值:找不到参数“()”和关键字参数“{}”的“密码重置完成”的相反值。已尝试0个模式:[] 在url.py中,我有:Python 升级Django和NoReverseMatch密码错误,python,django,Python,Django,我正在尝试将旧版本Django 1.5升级到新版本。 升级后,当我进入密码重置页面时,Django告诉我错误: 在/accounts/password/reset/ password_reset()获得意外的关键字参数“post_change_redirect” 请求方法:获取 TypeErrorRequestURL: Django版本:1.6.11 异常类型:TypeError 异常值: password_ResetSet()得到一个意外的关键字参数“post_change_redirect”
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>[\d\w-]+)/$', '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'),
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中,它可以正常工作,但在较新版本中会出现错误。
你知道有人怎么修吗??
谢谢
编辑:
我在URL.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'),
url(r'^password/reset/done/$,'django.contrib.auth.views.password\u reset\u done',name='password\u reset\u done'),
url(r'^password/reset/confirm/(?P[0-9A-Za-z\-]+)/(?P.+)/$,'django.contrib.auth.views.password\u reset\u confirm',name='password\u reset\u confirm'),
url(r“^password/reset/completed/$”、“django.contrib.auth.views.password\u reset\u complete”、name='password\u reset\u complete'),
url(r'^password/reset/$',passwd_reset,{'template_name':'emailing/registration activation/password_reset_email.html',name='password_reset'),
现在我有一个错误:
模板错误:
在template/home/martin/Work/wisepress.com/eshopwisepress/templates/email/registration-activation/password\u reset\u email.html中,第44行出现错误
>找不到带参数“()”和关键字参数“{u'uidb64':'',u'token':''}”的'django.contrib.auth.views.password_reset_confirm'的相反项。已尝试1个模式:[“帐户/密码/重置/确认/(?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_响应中的文件“/home/martin/Work/wisepress.com/virtualenv/local/lib/python2.7/site packages/django/core/handlers/base.py”
137response=response.render()
render中的文件“/home/martin/Work/wisepress.com/virtualenv/local/lib/python2.7/site packages/django/template/response.py”
105self.content=自渲染内容
呈现内容中的文件“/home/martin/Work/wisepress.com/virtualenv/local/lib/python2.7/site packages/django/template/response.py”
82content=template.render(上下文)
render中的文件“/home/martin/Work/wisepress.com/virtualenv/local/lib/python2.7/site packages/django/template/base.py”
140返回self.\u呈现(上下文)
文件“/home/martin/Work/wisepress.com/virtualenv/local/lib/python2.7/site packages/django/template/base.py”位于
134返回self.nodelist.render(上下文)
render中的文件“/home/martin/Work/wisepress.com/virtualenv/local/lib/python2.7/site packages/django/template/base.py”
840bit=self.render_节点(节点,上下文)
render_节点中的文件“/home/martin/Work/wisepress.com/virtualenv/local/lib/python2.7/site packages/django/template/debug.py”
78返回node.render(上下文)
render中的文件“/home/martin/Work/wisepress.com/virtualenv/local/lib/python2.7/site packages/django/template/defaulttags.py”
447六、重放(*exc_信息)
render中的文件“/home/martin/Work/wisepress.com/virtualenv/local/lib/python2.7/site packages/django/template/defaulttags.py”
433url=reverse(查看\名称,args=args,kwargs=kwargs,当前\应用程序=上下文。当前\应用程序)
文件“/home/martin/Work/wisepress.com/virtualenv/local/lib/python2.7/site packages/django/core/urlresolvers.py”的格式相反
536将iri_返回到_uri(解析器。_使用_前缀反向_(视图,前缀,*args,**kwargs))
文件“/home/martin/Work/wisepress.com/virtualenv/local/lib/python2.7/site packages/django/core/urlresolvers.py”位于带前缀的
456(查找\视图\参数、kwargs、len(模式)、模式)
异常类型:NoReverseMatch at/accounts/password/reset/
异常值:“django.contrib.auth.views.password_reset_confirm”与参数“()”和关键字参数“{u'uidb64':”,u'token:”}相反否