只需要在.ajaxSetup方法中设置csrfmiddlewaretoken即可
$.ajaxSetup({ data: {csrfmiddlewaretoken: '{{ csrf_token }}' }, });