cb9n1g
Last Updated: February 25, 2016
·
2.494K
· purak
Fe0a1519fcf6d2efd7f1a0bbc20660d2

Django's CSRF protection with AngularJS

If you want to make an AJAX request with AngularJS and Django rejects your calls due to CSRF token issues, try this.

Set a X-CSRFToken parameter to header for every call.

myApp.config(function($httpProvider) {
    var token = $('input[name=csrfmiddlewaretoken]').val();
    $httpProvider.defaults.headers.post['X-CSRFToken'] = token;
});
Say Thanks
Respond

1 Response
Add your response

8309
B97bf3c9ef3c1b92be966c36306b4234

Sick.

over 1 year ago ·