本文介绍了对于Django的CSRF故障中间件,如何让CSRF错误报告哪些URL失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
对于Django的CSRF失败中间件,您如何获取CSRF错误以报告哪些URL失败? csrf_failures(称为csrf_failure)的错误处理程序和request.path具有在CSRF失败期间被拒绝的URL。
def csrf_failure(request,reason =):
printCSRF failure:reason =%s,url =%s%(reason,request.path)
...
For Django's CSRF failure middleware, how can you get the CSRF errors to report what URL is failing?
解决方案I registered an error handler for csrf_failures (called csrf_failure) and the "request.path" has the url that was rejected during the CSRF failure.
def csrf_failure(request, reason=""): print "CSRF failure: reason=%s, url=%s" % (reason, request.path) ...
这篇关于对于Django的CSRF故障中间件,如何让CSRF错误报告哪些URL失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!