Skip to content

Conventions ​

Code ​

TopicConventionExample
StylePEP 8, checked by flake8lines of at most 79 characters
Namesclasses in PascalCase, functions and fields in snake_caseProductViewSet, created_at
Code languageEnglishhealth_check
Business rulesin the modelMinValueValidator(0)
Exposed fieldslisted explicitly in fieldsnever fields = '__all__'
Listsalways sorted.order_by('id')
Configurationenvironment variables, never hard-codedos.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.