You can add a date time encoder into the JSON jumps function when handling model querysets, this is customised a bit as I had issues with the base django model state being parsed
import datetime
import decimal
from django.db.models.base import ModelState
class DateTimeEncoder(json.JSONEncoder):
def default(self, obj):
if hasattr(obj, 'isoformat'):
return obj.isoformat()
elif isinstance(obj, decimal.Decimal):
return float(obj)
elif isinstance(obj, ModelState):
return None
else:
return json.JSONEncoder.default(self, obj)
Then use this class with your json dumps
b = json.dumps(a, cls = DateTimeEncoder)