I am trying to get the data from ajax to django post view, I create the cart with items now I need to get the cart to backend
My js code is:
$.ajax({
url: url,
type: "POST",
data: JSON.stringify({'order_data':order}),
contentType: 'application/json; charset=UTF-8',
success: function (data) {
if (data['success']) {
alert(data['success']);
}
},
error: function (request, error, status) {
if (request) {
}
}
});
My View code that I am using in Django view:
if request.method == "POST":
data = json.loads(request.body)
cart = data['order_data']
Then I am getting that error
RawPostException: You cannot access body after reading from request's data stream
your suggestions will be preferred