在SVN Trunk中完全禁用Django的CSRF保护
我沮丧地花了几个小时,试图禁用 Django 现在试图强加给我的 CSRF,但没有成功。还有其他人尝试过更成功吗?我对任何有效的东西都很好,除了源补丁(但猴子补丁还可以)。
I've spend a few hours in frustration, trying to disable the CSRF which Django now tries to force on me, to no avail. Had anyone else tried this with more success? I'm fine with anything that works, except for a source patch (but monkeypatches are okay).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不要这样做。但如果你必须这样做,试试这个。
Don't do it. But if you must, try this.
我实际上并没有尝试禁用它(从来没有需要),但我想这只是从 settings.py 中的 MIDDLEWARE_CLASSES 设置中删除 CSRF 中间件的问题。
I haven't actually tried to disable it (never had the need), but I imagine it's just a matter of removing the CSRF middleware(s) from the MIDDLEWARE_CLASSES setting in your settings.py.
尝试注释掉 csrf 中间件并重新启动服务器。很多时候像这样的变化直到事后才会被加载。
Try commenting out the csrf middleware and restarting the server. A lot of the time changes like that wont be loaded until afterward.