|
|
|
|
|
by skrtskrt
1825 days ago
|
|
In my opinion and experience, treating the model as anything but a way to talk to the database behind a service interface is a very slippery slope. My service methods receive and return pure objects (pydantic or attrs) that I serialize from the models. No other part of the app gets to pass around that service’s model, updating it willy nilly, maybe saving the updates, maybe not. The service completely hides the model and all corresponding persistence logic behind its interface. The decoupling you achieve is worth the extra boilerplate. It’s the only way I have ever seen Django apps not become giant balls of mud. |
|