[Django]-CSRF Error Django ajax .post with no form

3👍

try to add ensure_csrf_cookie decorator

from django.views.decorators.csrf import ensure_csrf_cookie

@ensure_csrf_cookie
def ajax_view(request):

and you don’t need {% csrf_token %} in template.html

Leave a comment