python - serialize datetime to json in Django -
hi how datetimefield mysql database in django in json format. got error when executed code 'date.time cannot serialized in json'(data holds lot of values)
data = json.dumps(data)
but fixed adding
all_data = serializers.serialize("json", data, ensure_ascii=false)
but 'str' object has no attribute '_meta'
this solved problem.
import json django.core.serializers.json import djangojsonencoder data = json.dumps(data, cls=djangojsonencoder)
Comments
Post a Comment