What is a best practice to receive JSON input in Django views?
django, json, python, rest
Solution
`request.POST` is pre processed by django, so what you want is `request.body`. Use a JSON parser to parse it.
import json
def do_stuff(request):
if request.method == 'POST':
json_data = json.loads(request.body)
# do your thing
Problem
I am trying to receive JSON in Django's view as a REST service. I know there are pretty developed libraries for REST (such as Django REST Framework). But I need to use Python/Django's default libraries.