2👍
You need to include {% csrf_token %} in your form ………..and inyour javascript file….
put something like this in your function(click,onload etc) from which you want to call ajax
var csrfmiddlewaretoken = document.getElementsByName("csrfmiddlewaretoken")[0].value;
dataString = "csrfmiddlewaretoken="+csrfmiddlewaretoken
$.ajax({
type: "POST",
url: "/path/to/view/",
data: dataString,
success: function(response){
});
Source:stackexchange.com