Backend for education.borshev.com
Django-based production project, integrated with Tinkoff, Dashamail, Postmark, S3 and telegram. Frontend is built on vue.js in the separate repo.
Configuration is stored in src/app/.env
, for examples see src/app/.env.ci
This project requires python 3.11. Python virtual environment should be installed and activated.
Deps are managed by pip-tools with requirements stored in pyproject.toml.
Install requirements:
pip install --upgrade pip pip-tools
make
Configure postgres and redis. It's convenient to use docker and docker-compose:
docker-compose up -d
If you don't have access to de-anonymized db image use postgres:13.6-alpine
in docker-compose.yml
instead:
postgres:
image: postgres:13.6-alpine
...
Run the server:
cd src && cp app/.env.ci app/.env # default environment variables
./manage.py migrate
./manage.py createsuperuser
./manage.py runserver
Testing:
# run lint
make -C .. lint
# run unit tests
make -C .. test
- Obey django's style guide.
- Configure your IDE to use flake8 for checking your python code. For running flake8 manualy, do
cd src && flake8
- Prefer English over your native language in comments and commit messages.
- Commit messages should contain the unique id of issue they are linked to (refs #100500)
- Every model and a model method should have a docstring.
- KISS and DRY.
- Obey django best practices
- If you want to implement some business logic — make a service for that. Service examples: UserCreator, OrderCreator
- No logic is allowed within the views or templates. Only services and models.
- Use PEP-484 type hints when possible.
- Prefer Manager methods over static methods.
- Do not use signals for business logic. Signals are good only for notification purposes.
- No l10n is allowed in python code, use django translation.