How to structure Django projects

Here are some notes on how to structure a Django project. It breaks away from structuring a project around Django “apps” and instead uses a clear separation between three core layers (data, domain, and interfaces). Let’s use the following example, an e-commerce site called “Crema” where people can purchase coffee goods. Below is a layout of the fundamental directories. src/ crema/ data/ migrations/ models/ domain/ baskets/ orders/ products/ users/ interfaces/ actions/ management/ commands/ dashboard/ orders/ products/ users/ store/ account/ basket/ checkout/ products/ tests/ functional/ unit/ The src/ directory lives in the root of the repository, alongside files such as README.md. The crema/ directory contains all the project files, and all the test files live in the tests/ directory. Let’s drill down into the three main layers. ...

June 25, 2018 · James Beith