我正在使用邮递员来测试我的django应用程序调用是否按预期工作但事实并非如此。
我收到以下错误:
ValueError at /mobile/emulate_create</title>
Exception Value: No JSON object could be decoded
我有以下代码:
@csrf_exempt
def emulate_create(request):
args = json.loads(request.body, object_hook=utils._datetime_decoder)
resourceId, count, hours = args['resourceId'], args['count'], args['hours']
now = datetime.now()
remainder = now.minute % 15
timeFrom = now + timedelta(minutes=remainder)
timeTo = timeFrom + timedelta(hours=hours)
reservation = ReservationProspect(byUser=request.user, forUser=request.user, resource=get_object_or_404(Resource, uuid=resourceId), modality=get_object_or_404(Modality, name="online"), timeFrom=timeFrom, timeTo=timeTo, count=count)
return HttpResponse(json.dumps[reservation.toDict()])
有谁看到这里可能会发生什么?