[Answer]-Json in views.py

0👍

TypeError: datetime.time(23, 51, 58) is not JSON serializable

Serialize/Stringify the datetime object first before using json.dumps or simplejson.dumps. Python’s integrated json serializer can not work with datetime “types”, just with built-in types like int, float, str, etc..

1👍

from django.core import serializers

json_serializer = serializers.get_serializer("json")
response =  json_serializer.serialize(list, ensure_ascii=False, indent=2, use_natural_keys=True)
return HttpResponse(response, mimetype="application/json")

Please check this or this

👤Nick

Leave a comment