Django json.dump(data) throws error ‘datetime (...) is not JSON serialzable.’ because default it
only does queryset json serialization. Use below to serialize dates.
from django.core.serializers.json import DjangoJSONEncoder
def test(request, title):
…
data = json.dumps(qset, cls=DjangoJSONEncoder)
data = json.dumps(qset, cls=DjangoJSONEncoder)
This should resolve the issue.
No comments:
Post a Comment