Search code examples
pythondjangodjango-csrf

Django 1.4 without the csrf_token


I've just upgraded Django from 1.2.3 to 1.4 and realized that django.middleware.csrf.CsrfResponseMiddleware is depricated. Is there some other way where I don't have to use the csrf_token in every post? It will be easier for the front end designers to not have to worry about django specific tokens.


Solution

  • Check the doc, especially csrf_exempt and csrf_protect decorators.

    You could then use django.middleware.csrf.CsrfViewMiddleware for default csrf protecting w/ csrf_exempt to exempt special views; or only use csrf_protect for each view to protect.