4 ms·
That logic has to go somewhere right? I'm not sure what the issue is. There's the "heuristic" of expecting a property to not be expensive to access (which djan
by rajin444 5y ago
That logic has to go somewhere right? I'm not sure what the issue is.
There's the "heuristic" of expecting a property to not be expensive to access (which django already kind of throws out the window depending on how you fetch the model), but otherwise I don't see how services fixes this. Is copy and pasting that code over to a services.py file better?
Services are very nice for dealing with python's import issue. Accessing other models from a method / property on a model is ugly. But it's very hard to structure and name services in a logical way, especially when the lines start to cross. You end up with a "shared_services.py".
- mtoddsmith 5y agoKeeping the business logic in a service (aka Anemic Model in Domain Driven Design terms) allows you to change the business logic using different versions of the same service. You can then inject the appropriate implementation for a given context using IoC (Inversion of Control).
- bebop 5y agoThis is hugely important when you need to do a migration of your data store.