I'm new to both Django and AngularJS and I've been struggling on this for hours.
AngularJS Code (of my controller) to POST to Django Server:
$http({
method: 'POST',
url: 'http://127.0.0.1:8000/polls/', // This is the Django server IP
data: {'string': 'body'}
}).then(function successCallback(response) {
$scope.var= "success";
}, function errorCallback(response) {
$scope.var= response; // To display error.
});
}
})
Django Server Code (in view):
def index(request):
return "true"
The exact error that I'm getting is: POST http://127.0.0.1:8000/polls/ 403 (Forbidden)
Details of error- CSRF verification failed. Request aborted.You are seeing this message because this site requires a CSRF cookie when submitting forms. This cookie is required for security reasons, to ensure that your browser is not being hijacked by third parties. Blah blah.
EDIT Would prefer solutions that would work without affecting any of the security provisions of Django