CSRF中间件 - 更改csrf_token输出(从xHTML到HTML) [英] CSRF Middleware - change csrf_token output (from xHTML to HTML)

查看:261
本文介绍了CSRF中间件 - 更改csrf_token输出(从xHTML到HTML)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个django csrf中间件的问题...
当我使用模板标签csrf_token我得到这个输出:

I've a problem with django csrf middleware... when I use the template tag csrf_token I get this output:

<div style='display:none'><input type='hidden' name='csrfmiddlewaretoken' value='6bda3605af31dd8595d2a67d0dda827b' /></div>

但是我想要输出(HTML不是xHTML:

but I want this output (HTML not xHTML:

<div style='display:none'><input type='hidden' name='csrfmiddlewaretoken' value='6bda3605af31dd8595d2a67d0dda827b'></div>

我尝试看到django.middleware.csrf.CsrfViewMiddleware中的代码,但没有成功:(

I tryed to see the code in django.middleware.csrf.CsrfViewMiddleware but with no success :(

那么,如何更改输出fo csrf_token标签?

So, how can I change the output fo csrf_token tag?

tank

推荐答案

你必须去编辑django.template.defaulttags.py:在第48行有标签的输出,你可以根据需要更改它

You have to go and edit django.template.defaulttags.py: At line 48 there is the output of the tag, and you may change it as you wish.

请注意,这是一项开发功能,因此可能会更改 - 更新Django可能会删除您的更改!

另请参见请花时间去寻找机票关于这个特殊问题:我提出的解决方案ed可能会解决你的问题,但我认为官方的修复会更好一些。

Please note that this is a development feature, and as such, subject to change - updating Django will likely remove your change!.
Also, please take the time to go look for a ticket about this particular problem: the solution I proposed will likely fix your problem, but I think that an "official" fix would be a lot nicer.

这篇关于CSRF中间件 - 更改csrf_token输出(从xHTML到HTML)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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