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 1 year, 10 months ago
  2. Middleware to resolve current URL to module and view by kuchin 2 years, 10 months ago
  3. CSRF this! by oggy 4 years, 8 months ago
  4. RequestMiddleware by martync 3 years, 10 months ago
  5. Strip Google Analytics cookies for caching middleware purposes by nf 3 years, 6 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?)