For Django1.6 +, check the accepted answer. For Django1.5 and prev, there is no parameter for this.
You can override the process_response() django.middleware.csrf.CsrfViewMiddleware and use custom instead of CsrfViewMiddleware in MIDDLEWARE_CLASSES
class Foo(CsrfViewMiddleware): def process_response(self, request, response): response = super(Foo, self).process_response(request, response) response.cookies[settings.CSRF_COOKIE_NAME]['httponly'] = True return response
Or in another middleware that is called after CsrfViewMiddleware in response
class Foo(object): def process_response(self, request, response): if settings.CSRF_COOKIE_NAME in response.cookies: response.cookies[settings.CSRF_COOKIE_NAME]['httponly'] = True return response
okm
source share