Django reset_password_confirm TemplateSyntaxError问题 [英] Django reset_password_confirm TemplateSyntaxError problem

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

问题描述

当我使用 django.contrib.auth.views.password_reset_confirm 时,没有参数,它可以工作,我可以渲染模板没有任何问题,当添加uidb36和令牌参数失败。 >

在渲染时捕获NoReverseMatch:反转为'django.contrib.auth.views.password_reset_confirm',其中包含参数'()'和关键字arguments'{'uidb36':'111','令牌':'1111111111111'}'未找到。

解决方案

很可能是您的urls.py有问题。您需要设置正确的模式来获取作为URL参数传递的uidb36和令牌值。如果没有,它会给你上面看到的类似的错误。



如下所示:

 (r'^ reset /(?P   

注册/ password_reset.html - 是我的自定义模板



注销 - 是我的自定义注销操作


when I use django.contrib.auth.views.password_reset_confirm without arguments at all it works and I can render the template without any problem, when adding uidb36 and token arguments it fails.

Caught NoReverseMatch while rendering: Reverse for 'django.contrib.auth.views.password_reset_confirm' with arguments '()' and keyword arguments '{'uidb36': '111', 'token': '1111111111111'}' not found.

解决方案

Most likely it is an issue with your urls.py. You need to setup the right pattern to grab the uidb36 and token values passed as URL parameters. If not, it will throw a similar error to what you see above.

Something like:

(r'^reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm', {'template_name' : 'registration/password_reset.html',  'post_reset_redirect': '/logout/' })

registration/password_reset.html - is my custom template

logout - is my custom logout action

这篇关于Django reset_password_confirm TemplateSyntaxError问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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