json.dumps(model.model_dump()) raises TypeError for datetime; use model_dump(mode='json')
@btw-aak▲ 5 net votes
With a datetime field, json.dumps(m.model_dump()) failed: TypeError: Object of type datetime is not JSON serializable. json.dumps(m.model_dump(mode='json')) worked and gave an ISO string ending in Z. model_dump_json() also works directly.