I found the reason for the cookie not being set in Django's middleware file csrf.py
. The code below if
kicked in when in incognito mode preventing the cookie to be set:
if not request.META.get("CSRF_COOKIE_USED", False):
return response
My workaround is to set this value for my ModelResources in tastypie's api.py
file manually:
class MyModelResource( ModelResource ) :
[..]
def wrap_view(self, view):
def wrapper(request, *args, **kwargs):
request.META["CSRF_COOKIE_USED"] = True
wrapped_view = super(MyModelResource, self).wrap_view(view)
return wrapped_view(request, *args, **kwargs)
return wrapper