CodeOath
← All posts
Python70 min total · 18 parts

Django Fundamentals: MVT Architecture, the ORM, and Middleware

Contents — Part 3 of 18: Project and App Structure
Part 3 of 18 · ~1 min

Project and App Structure

A Django project is the overall configuration; an app is a self-contained module of functionality (models, views, templates) meant to be reusable and pluggable:

myproject/
├── manage.py
├── myproject/          # the project package — settings, root URLs
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py / asgi.py
└── orders/             # an app — one focused piece of functionality
    ├── models.py
    ├── views.py
    ├── urls.py
    ├── admin.py
    ├── apps.py
    └── migrations/

A project can, and typically does, contain several apps (orders, accounts, catalog). The split matters in practice: apps are meant to be loosely coupled enough that one could theoretically be lifted into a different project, which is why cross-app imports and tight coupling between two apps' models is usually a design smell worth noticing. Every app must be registered in settings.py's INSTALLED_APPS list before Django will discover its models, admin registrations, or template tags.