I had the same problem. I had been posting a complex JSON response, and I couldn't read my data using the request.POST dictionary.
My JSON POST data was:
//JavaScript code:
//Requires json2.js and jQuery.
var response = {data:[{"a":1, "b":2},{"a":2, "b":2}]}
json_response = JSON.stringify(response); // proper serialization method, read
// http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/
$.post('url',json_response);
In this case you need to use method provided by aurealus. Read the request.body and deserialize it with the json stdlib.
#Django code:
import json
def save_data(request):
if request.method == 'POST':
json_data = json.loads(request.body) # request.raw_post_data w/ Django < 1.4
try:
data = json_data['data']
except KeyError:
HttpResponseServerError("Malformed data!")
HttpResponse("Got json data")