Reputation: 2895
I'm using Angular to post some data to a Django endpoint with:
$http({
method: 'POST',
url: '/api/projects/166/interval_sort/',
data: JSON.stringify({ids: [251,250,249,235,233,234]})
})
And in my view method, request.POST is an empty <QueryDict: {}>
def ProjectIntervalSort(request, pk):
logger.debug("SORTABLE DATA: "+str(request.POST))
return HttpResponse(status=204)
Chrome's network inspector shows my JSON object being sent, but I don't seem to be able to access it from the Django side. Am I not formatting the data correctly or missing something in my view method? Thanks.
Upvotes: 1
Views: 503
Reputation: 599628
request.POST
is for form-encoded data. You're using JSON, and you can find it in request.body
.
Upvotes: 3