serialize datetime to json in Django
DjangoJSONEncoder 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.