I’ve been mulling many of these points with respect to my projects and here are my thoughts:
- Fat models are okay at the start, but seem to become a problem the more the app grows
- A separate module for “business logic” is probably a good idea
- I think models are a “low level” interface to your data(base). And should not be much more.
- I call the business logic module “logic”. Others seem to call it “services”.
- When you need to implement a process that writes to one model then I think a manager is the way to go.
- When you need to implement a process that needs to write to two or more models, then I think you might want to use the “logic” module
- If you want to read any data that depends only on one model, then you can use model methods
- If you want to read data that depends on more than one model, you might want to use the “logic” module. The exception to this I think would be when a model is conceptually “nested” in another (via a
foreign key) then it may be natural to use model methods. - The logic can be reused in views, api calls, celery tasks / cron jobs, management commands
- The logic module is a natural interface to your app.
- Forms are also a natural interface to your app. However I would keep form logic simple, and if it gets complicated (e.g. requires writing to two or more models) then factor that logic out into your logic module.
Hope this helps someone!