I want to send an ajax request (via jQuery, although I think it doesn't matter in this situation) without using the form element in Django. According to the documentation , I have to do this using the ensure_csrf_cookie decorator, however, I get Error was: cannot import name ensure_csrf_cookie .
I am using the following import from django.views.decorators.csrf import ensure_csrf_cookie .
I did not find much documentation on ensure_csrf_cookie , so any help would be ensure_csrf_cookie appreciated.
By the way, using @csrf_exempt works as expected.
Thanks in advance.
source share