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

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

问题描述

当我在没有任何参数的情况下使用 django.contrib.auth.views.password_reset_confirm 时,它可以正常工作并且我可以毫无问题地呈现模板,但在添加 uidb36 和令牌参数时它会失败.

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.

在渲染时捕获 NoReverseMatch:使用参数 '()' 和关键字参数 '{'uidb36': '111', 'token': '11111111111111'}' 反转 'django.contrib.auth.views.password_reset_confirm'找到了.

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

推荐答案

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

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.

类似于:

(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 - 是我的自定义模板

registration/password_reset.html - is my custom template

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

logout - is my custom logout action

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

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