0

For Django's CSRF failure middleware, how can you get the CSRF errors to report what URL is failing?

MikeN
  • 45,039
  • 49
  • 151
  • 227

1 Answers1

1

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)
    ...
MikeN
  • 45,039
  • 49
  • 151
  • 227