[Django]-Cant get AngularJS's $http.post data in Django

5👍

Actually, when we send data from AngularJs using $http’s POST, it sends the data with the content-type = “application/json” to the server. And Django doesn’t understand that format. And so you can’t get the sent data.

Solution is to change the content-type header by using following config:

    app.config(['$httpProvider', function ($httpProvider) {
        $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
}]);

Leave a comment