The main django app is called core
. It contains .env
file for django-environ. For examples see src/core/.env.ci
. Here are some usefully app-wide tools:
core.admin
— app-wide django-admin customizations (empty yet), check out usage examplescore.test.api_client
(available asapi
andanon
fixtures within pytest) — a convinient DRF test client.
Django's user model is located in the separate users
app.
Also, feel free to add as much django apps as you want.
Running a project with docker (preferred method)
- Install docker and docker compose suitable for your operating system. official docker website
docker compose version
~ Docker Compose version v2.2.3
-
Clone a project in /your_dir/
-
Create a .env file and add variables as per "/your_dir/main/infra/.env.example"
cd /your_dir/main/ # go to main dir
touch .env # create .env file
nano .env # open the .env file and add variables as in .env.example
- Start project.
docker compose up --build -d
Run the project by installing all packages
This project requires python 3.11. Deps are managed by [Poetry](https://python-poetry.org/docs/).
Install requirements:
Install Poetry If you haven't already, you need to install Poetry, a tool for managing Python dependencies. You can find the installation guide at python-poetry.org.
Install Ruff If you haven't already, you need to install Ruff, a tool for linting code. You can find the installation guide at docs.astral.sh/ruff.
Run the server:
$ cd src && cp core/.ci.env core/.env # default environment variables
$ ./manage.py migrate
$ ./manage.py createsuperuser
$ ./manage.py runserver
Testing(run it before pushing your code):
# run lint
$ make lint
# fix lint issues
$ make fmt
# run unit tests
$ make test
Development servers:
# run django dev server
$ ./manage.py runserver
- Obey django's style guide.
- Configure your IDE to use Ruff for checking your python code. To run our linters manualy, do
make lint
- 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, service and model method should have a docstring.
- KISS and DRY.
- Obey django best practices.
- No logic is allowed within the views or serializers. Only services and models. When a model grows beyond 500 lines of code — go create some services.
- Use PEP-484 type hints when possible.
- Prefer composition to inheritance.
- Never use signals or GenericRelations in your own code.
- No l10n is allowed in python code, use django translation.