Hi how do i get DateTimeField from mysql database in django in json format. I got an error when i executed the code 'Date.time cannot be serialized in json'(data holds a lot of values)
data = json.dumps(data)
but this was fixed by adding
ALL_data = serializers.serialize("json", data, ensure_ascii=False)
But now i get 'str' object has no attribute '_meta'
This solved my problem.
import json from django.core.serializers.json import DjangoJSONEncoder data = json.dumps(data, cls=DjangoJSONEncoder)
Django's serializers are only meant to be used on query sets; you will have to find a different way to solve your problem, such as converting the
datetime to something else first.