request body django

Solutions on MaxInterview for request body django by the best coders in the world

showing results for - "request body django"
Davide
17 Oct 2017
1In Python 3.0 to Python 3.5.x, json.loads() will only accept a unicode string, so you must decode request.body (which is a byte string) before passing it to json.loads().
2
3body_unicode = request.body.decode('utf-8')
4body = json.loads(body_unicode)
5content = body['content']
6In Python 3.6, json.loads() accepts bytes or bytearrays. Therefore you shouldn't need to decode request.body (assuming it's encoded in UTF-8, UTF-16 or UTF-32).