To send a datetime.datetime object in serialized form from Python using JSON and deserialize in JavaScript using JSON. You can add the 'default' parameter to json.dumps to handle this:
date_handler = lambda obj:(
obj.isoformat()
if isinstance(obj, (datetime.datetime, datetime.date))
else None
)
json.dumps(datetime.datetime.now(), default=date_handler)