31 ms·
The issue with fat models is that if you use DB models and then put business logic in there (assuming that's what you mean by fat models), things fail pretty qu
by adsharma 5y ago
The issue with fat models is that if you use DB models and then put business logic in there (assuming that's what you mean by fat models), things fail pretty quickly.
But like you rightly point out here that is not a good reason to avoid class based views. They can be simple to understand and maintain.
What I've found useful is to maintain a two level hierarchy. I've used the term "view models" to describe the classes that feed into CBVs and "db models" for django models.
They could both be dataclasses with declarative mapping between the two, so you don't write the tedious code of parsing database results into view models.
More thoughts on the topic here:
https://adsharma.github.io/flattools-programs/
https://github.com/adsharma/fquery/commit/cdcbfca4e140c0b91b2a6e7f270af06225383cf2