Conventions
Code
| Topic | Convention | Example |
|---|---|---|
| Style | PEP 8, checked by flake8 | lines of at most 79 characters |
| Names | classes in PascalCase, functions and fields in snake_case | ProductViewSet, created_at |
| Code language | English | health_check |
| Business rules | in the model | MinValueValidator(0) |
| Exposed fields | listed explicitly in fields | never fields = '__all__' |
| Lists | always sorted | .order_by('id') |
| Configuration | environment variables, never hard-coded | os.getenv('DB_HOST') |
Tests
- One test class per resource:
ProductAPITests,HealthCheckTests. - A test name that says what it checks:
test_reject_negative_price. - Test the HTTP code and the effect in the database (
refresh_from_db,exists()). - Tests run on SQLite: do not use a PostgreSQL-specific function without saying so.
Migrations
- A migration is committed with the model change that produced it.
- Never edit a migration already merged into
develop: write a new one.
Git
feature/* branches → merge request to develop. Messages feat(api): …, fix(api): …. See The Git repository.