Ignore Csrf Middleware

1
2
3
class IgnoreCsrfMiddleware(object):
    def process_request(self, request):
        request.csrf_processing_done = True

More like this

  1. Add CSRF token to templates by coleifer 2 years, 9 months ago
  2. Manual CSRF check for Django Facebook canvas applications by krvss 2 years, 7 months ago
  3. CSRF this! by oggy 5 years, 6 months ago
  4. HttpMethodsMiddleware by hawkeye 7 years ago
  5. create_c by catellar 2 years, 7 months ago

Comments

adonm (on June 20, 2010):

Works great - to clarify you add it like so (in settings.py):

class IgnoreCsrfMiddleware(object):
    def process_request(self, request):
        request.csrf_processing_done = True

MIDDLEWARE_CLASSES = (
    'settings.IgnoreCsrfMiddleware',
    'django.contrib.csrf.middleware.CsrfMiddleware',
    ...
    )

#

meitham (on June 24, 2010):

If you are going to ignore the csrf why adding the middleware in the first place?

#

(Forgotten your password?)