Suppose you’re working on a Django project that you’re not sure is going to get complex enough to warrant the patterns we recommend, but you still want to put a few steps in place to make your life easier, both in the medium term and if you want to migrate to some of our patterns later. Consider the following: One piece of advice we’ve heard is to put a logic.py into every Django app from day one. This gives you a place to put business logic, and to keep your forms, views, and models free of business logic. It can become a stepping-stone for moving to a fully decoupled domain model and/ or service layer later. A business-logic layer might start out working with Django model objects and only later become fully decoupled from the framework and work on plain Python data structures. For the read side, you can get some of the benefits of CQRS by putting reads into one place, avoiding ORM calls sprinkled all over the place. When separating out modules for reads and modules for domain logic, it may be worth decoupling yourself from the Django apps hierarchy. Business concerns will cut across them.7403 ↱
Architecture Patterns with Python
Enabling Test-Driven Development, Domain-Driven Design, and Event-Driven Microservices
Harry Percival, Bob Gregory