Take a look at django/middleware/csrf.py , which CsrfViewMiddleware class. As you can see in def process_response(self, request, response) , there are three conditions that prevent the setting of cookies:
def process_response(self, request, response): if getattr(response, 'csrf_processing_done', False): return response
Check which one applies to you.
source share