Ignore Csrf Middleware

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

More like this

  1. CSRF this! by oggy 3 years, 8 months ago
  2. Add CSRF token to templates by coleifer 10 months, 3 weeks ago
  3. Django csrf_token Template Tag Fix by Reustle 1 year, 9 months ago
  4. csrf_token for mako by damd 1 year, 12 months ago
  5. Manual CSRF check for Django Facebook canvas applications by krvss 8 months, 2 weeks 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?)