I have this code
json.loads(request.POST.get('mydata',dict()))  But I get this error
No JSON object could be decoded  I just want that if don't have mydata in POST, then I don't get that error.
Simply:
json.loads(request.POST.get('mydata', '{}'))   Or:
data = json.loads(request.POST['mydata']) if 'mydata' in request.POST else {}   Or:
if 'mydata' in request.POST:     data = json.loads(request.POST['mydata']) else:     data = {} # or data = None 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With