Login

Ignore Csrf Middleware

Author:
coleifer
Posted:
June 17, 2010
Language:
Python
Version:
1.2
Tags:
middleware csrf
Score:
2 (after 2 ratings)

Add to your middleware classes before 'django.middleware.csrf.CsrfViewMiddleware'.

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

More like this

  1. Always have CSRF and Session cookies by andrew 1 year, 1 month ago
  2. Add CSRF token to templates by coleifer 5 years, 1 month ago
  3. Manual CSRF check for Django Facebook canvas applications by krvss 4 years, 11 months ago
  4. CSRF this! by oggy 7 years, 11 months ago
  5. HttpMethodsMiddleware by hawkeye 9 years, 4 months ago

Comments

adonm (on June 20, 2010):
<p>Works great - to clarify you add it like so (in settings.py):</p> <pre>class IgnoreCsrfMiddleware(object): def process_request(self, request): request.csrf_processing_done = True MIDDLEWARE_CLASSES = ( 'settings.IgnoreCsrfMiddleware', 'django.contrib.csrf.middleware.CsrfMiddleware', ... ) </pre>

#

meitham (on June 24, 2010):
<p>If you are going to ignore the csrf why adding the middleware in the first place?</p>

#

Please login first before commenting.