Получаю ошибку в строке json.dumps(data) if dump else data
:
def JsonResponse(data, dump=True, status=None):
status = status or httplib.OK
if 'errors' in data:
data['success'] = False
elif 'code' in data:
data['success'] = False
elif 'success' not in data:
data['success'] = True
return HttpResponse(
json.dumps(data) if dump else data,
content_type=JSON_MIMETYPE,
status=status,
)
Код выше вызывается через этот декоратор:
def wrap_json(f):
@functools.wraps(f)
def _wrap_json(request, *args, **kwargs):
try:
response = f(request, *args, **kwargs)
except ValidationError as e:
return lib_http.JsonResponseBadRequest(
json.loads(e.message),
lib_errors.BAD_REQUEST,
)
except Exception as e:
log.exception(str(e) or 'wrap_json', request=request)
return lib_http.JsonInternalServerError("Internal Server Error. Try again later.")
if shouldnt_handle(response):
return response
return lib_http.JsonResponse(response)
return _wrap_json
Получаю ошибку
TypeError: Object of type datetime is not JSON serializable