Этот репозиторий содержит два отдельных приложения одно на django, django-rest-framework и другое на fastapi
Django Task Manager - это веб-приложение для управления задачами, разработанное на Django и Django REST Framework. Приложение предоставляет полный цикл CRUD (Create, Read, Update, Delete) операций для управления задачами с системой аутентификации пользователей.
FastAPI Task Manager - это это высокопроизводительный микросервис для управления задачами, построенный на современном асинхронном фреймворке FastAPI. Сервис предоставляет полный цикл CRUD (Create, Read, Update, Delete) управления задачами.
По поводу тестирования приложения на django сразу хотел сказать, что видел, какие фреймворки указаны в тестовом задании, но всё равно решил, что целесообразнее использовать встроенное джанговское тестирование. Объясню почему: я не вижу смысла использовать тут pytest или другие фреймворки для тестирования — это нужно заморачиваться с конфигами, импортами всего settings и так далее. В Django уже всё готово для тестирования, просто пиши. Тестирование на fastapi приложении реализованно на pytest.
Docs
| AUTHORIZE | GET | GET_LIST |
|---|---|---|
![]() |
![]() |
![]() |
| CREATE | UPDATE | DELETE |
|---|---|---|
![]() |
![]() |
![]() |
Docs
| GET | GET_LIST |
|---|---|
![]() |
![]() |
| CREATE | UPDATE | DELETE |
|---|---|---|
![]() |
![]() |
![]() |
.github/
├── workflows/
├── test.yaml # A CI file for the backend app that consists of `test`
django_task_manager/
├── core
├── asgi.py # ASGI configuration for asynchronous servers (example: Django Channels)
├── settings.py # Root settings: database, applications, middleware, secret
├── urls.py # Root urls (connects urls from other applications)
├── wsgi.py # WSGI config for sync(ordenary server)
├── tasks
├── admin.py # Register your models(db)
├── apps.py # Config this app(connect signals)
├── models.py # Implemented modeld(db)
├── serializers.py # Data serializer serializes from python objects to json and vice versa
├── tests.py # Testing your apps(tasks)
├── urls.py # Tasks application url routes
├── views.py # request handlers(take data from the database, can do something with it and insert it into the template)
├── Docker # Docker configuration file for backend application FastAPI
├── .pylintrc # Config linter for Django
fastapi_task_manager/
├── app/
├── api/
├── dependencies/ # Dependency injections
├── session.py
├──repository.py
├── routes/ # Endpoints
├── tasks.py # task routes
├── endpoints.py # Endpoint task(crud)
├── config/
├── settings/
├── base.py # Base settings / settings parent class
├── development.py # Development settings (prod, test in feature)
├── environments.py # Enum with PROD, DEV, STAGE environment
├── events.py # Registration of global events
├── manager.py # Manage get settings
├── models/
├── db/
├── task.py # task class for database entity
├── schemas/
├── account.py # Account classes for data validation objects
├── base.py # Base class for data validation objects
├── repository/
├── crud/
├── task.py # C. R. U. D. operations for Task entity
├── base.py # Base class for C. R. U. D. operations
├── database.py # Database class with engine and session
├── events.py # Database events
├── table.py # Custom SQLAlchemy Base class
├── utils/
├── exceptions/
├── database.py # Custom `Exception` class
├── formatters/
├── datetime_formatter.py # Reformat datetime into the ISO form
├── field_formatter.py # Reformat snake_case to camelCase
├── main.py # Our main backend server app
├── tests/
├── api/ # Integration API tests
├── unit_tests/ # Unit tests
├── test_model.py # Testing model
├── test_repo.py # Testing repo (crud)
├── test_schemas.py # Testing schemas
├── conftest.py # The fixture codes and other base test codes
├── Dockerfile # Docker configuration file for backend application FastAPI
├── .pylintrc # Config linter for FastAPI
README.md # Documentation for backend app
requirements.txt # Packages installed for backend app
.dockerignore # A file that list files to be excluded in Docker container
.gitignore # A file that list files to be excluded in GitHub repository
.pre-commit-config.yaml # A file with Python linter hooks to ensure conventional commit when committing
README.md # The main documentation file for this template repository
docker-compose.yaml # The main configuration file for setting up a multi-container Docker (Django, FastAPI, PostgreSQL)Клонируйте репозиторий:
git clone https://github.com/wpotoke/task_manager.git
cd task_managerАктивируйте виртуальное окружени и установите зависисмости:
python -m venv venv && venv\Scripts\activate
pip install -r requirements.txt
Создайте файл переменных окружения .env по примеру .env.example, остальное будет доступно из коробки
SECRET_KEY = secret key
NAME = "NAME_DB"
USER = "USERNAME"
PASSWORD = "PASS"
fastAPI_POSTGRES_DB=db name
fastAPI_POSTGRES_PASSWORD=password from user
fastAPI_POSTGRES_USERNAME=username
Сгенерируйте SECRET_KEY (если необходимо) и вставьте его в файл .env:
python -c "import secrets; print(secrets.token_urlsafe(32))"Создайте пользователя и базу данных, также передайте права на пользование и укажите кодировку(вставьте данные в env) (pqsl)
CREATE USER your_username WITH PASSWORD 'your_password';
CREATE DATABASE your_databasename OWNER your_username ENCODING 'UTF8' LC_COLLATE 'ru_RU.UTF8' LC_CTYPE 'ru_RU.UTF8' TEMPLATE=template0;
Соберите и запустите контейнеры:
docker-compose up --buildПримените миграции
docker-compose exec django python manage.py makemigrations
docker-compose exec django python manage.py migrate
Создайте админа
docker-compose exec django python manage.py createsuperuser
Username (leave blank to use 'task_manager'): root
Email address: enter
Password: root
Password (again): root
The password is too similar to the username.
This password is too short. It must contain at least 8 characters.
This password is too common.
Bypass password validation and create user anyway? [y/N]: y
Superuser created successfully.
Потыкать проверить работу
После данных действие будет доступно два приложения
Djanfo - 127.0.0.1:8000/api/v1/docs/ FastAPI - 127.0.0.1:8001/docs
Django
docker-compose exec django python manage.py test
FastApi
docker-compose exec fastapi pytest
Django
| FILES | FUNCTIONS | CLASES |
|---|---|---|
![]() |
![]() |
![]() |
FastApi
| FILES | FUNCTIONS | CLASES |
|---|---|---|
![]() |
![]() |
![]() |





















