A simple Categories API that stores category tree to database and returns category parents, children and siblings by category id.
Use of any other third-party libraries or Django extensions (mptt, treebread, etc) is prohibited.
- Add unit tests for views
- Add integration tests (E2E, repositories)
- Docker >= 18.06.0
- Docker Compose >= 1.23.0
You can find contribution guide here.
Also you can read a very nice guide about commit messages.
make build
make up-d
make logs
make migrate
You can find more information about supportable command in the Makefile
.
-
Lock poetry dependencies:
- Change
pyproject.toml
file - Generate
poetry.lock
file:poetry lock --no-update
- Change
-
Run tests:
make tests
-
To create migrations use
make makemigrations
command -
To run migrations use
make migrate
command -
To enter inside containers use:
make shell-app
make shell-db
-
Linters:
make lint
- run all linters checks:make format-check
- to check code formatting (black and isort)make flake8
- to check code formatting (flake8)make mypy-check
- to check code types using mypy
make format
- to format code using black and isort
-
To check project source code metrics you can use Radon:
make radon-check
name | type | required | default |
---|---|---|---|
POSTGRES_ALCHEMY_DRIVER | str | true | none |
POSTGRES_HOST | str | true | none |
POSTGRES_PORT | int | true | none |
POSTGRES_WORK_DB | str | true | none |
POSTGRES_WORK_USER | str | true | none |
POSTGRES_WORK_USER_PASSWORD | str | true | none |
SECRET_KEY | str | true | none |
DJANGO_SUPERUSER_USERNAME | str | false | none |
DJANGO_SUPERUSER_EMAIL | str | false | none |
DJANGO_SUPERUSER_PASSWORD | str | false | none |
It is possible to avoid RecursiveField and create your own realization:
from rest_framework import serializers
class RecursiveField(serializers.Serializer):
pass
class CategorySerializer(serializers.Serializer):
name = serializers.CharField()
children = serializers.ListField(
child=RecursiveField(), allow_null=True, required=False
)
def get_fields(self):
fields = super().get_fields() or []
fields['children'] = CategorySerializer(many=True)
return fields