loads() takes a formatted json string and turns it into a Python object such as dict or list. In your code, you pass dict() as the default value if mydata does not exist in request.POST , while it should be a string, for example "{}" . So you can write -
json_data = json.loads(request.POST.get('mydata', "{}"))
Also remember that the request.POST['mydata'] value must be JSON formatted, otherwise you will get the same error.
Bibhas debnath
source share