Hacker News new | ask | show | jobs
by mr_Fatalyst 86 days ago
The way I see it, having everything as Pydantic makes this natural. Your DB model, your request schema, your response DTO are all BaseModels. Converting between them is just model_dump() and model_validate(), or plain inheritance. No adapters, no mapping layers. So when you need to split things apart, it's straightforward rather than painful.
1 comments

Yeah, but I'm afraid of a system like Django where not calling `.save()` in the wrong place is down to discipline and understanding. I want there to be some way to stop this happening that doesn't rely on a couple of maintainers keeping strict vigilance over the codebase.