[Answered ]-How to read json data in django?

2👍

✅

You are shadowing the json module with a local variable by using the same name, try using a different variable name instead.

def post_article(sample):      #sample is the http request   
    json_data = sample.read()
    data = json.loads(json_data) 
    a = data['title']
    response_data = {}
    response_data['title'] = a 
    return HttpResponse(json.dumps(response_data), content_type="application/json")

Leave a comment