<One sentence: what this Django project does.>
Stack
-
Python <3.12+>, Django <5.x>, <Django REST Framework Django Ninja> - PostgreSQL; Celery + Redis for background jobs
- Tests: pytest + pytest-django <or Django’s test runner>
Commands
- Run:
python manage.py runserver - Tests:
pytest -q(one:pytest apps/orders/tests/test_api.py -k refund) - Make migrations:
python manage.py makemigrations <app>; show SQL:python manage.py sqlmigrate <app> <number> - Migrate:
python manage.py migrate - Check:
python manage.py check --deploybefore release changes - Lint/format:
ruff check --fix . && ruff format .
Layout
config/settings (split:base.py,dev.py,prod.py), urls, wsgi/asgiapps/<name>/models, views/viewsets, serializers, services, tests
Rules
- Business logic in
services.py(or model methods), not in views or serializers. - Avoid N+1 queries: use
select_related/prefetch_related; check with the test client anddjango_assert_num_queriesor the debug toolbar. - Every model change ships with a migration in the same commit; review
sqlmigrateoutput for locking operations on large tables. - Data migrations use
apps.get_model, not direct model imports, and must be reversible or explicitlyRunPython.noopon reverse. - Permissions checked in every view (
permission_classesor explicit checks); querysets filtered to the current user/tenant. - Never commit
DEBUG = Truefor production settings or secrets in settings files.
Definition of done
- Tests pass,
makemigrations --checkreports no missing migrations, ruff clean.