FastAPI with Django ORM and Admin
Overview
This is a template repository for implementing the server using Django functionality for the DB area (admin, ORM) and FastAPI for the API area.
Prerequisites
Poetry
Dependency management for Python files is done using POETRY.
- https://python-poetry.org/docs/#installation
python -m venv venv
source venv/bin/activate
pip install --upgrade pip
(if needed)poetry install
pre-commit (for developers)
This tool defines commands to be executed before committing. It is already defined in .pre-commit-config.yaml
, so you need to configure it in your environment. Please follow the steps below.
- https://pre-commit.com/#installation
pre-commit install
Usage
-
Clone this repository
git clone https://github.com/kathmandu777/fastapi-django-template.git
-
Create fastapi.env with reference to fastapi.env.tmpl
-
Build
docker-compose build
-
Dependency install
docker-compose run --rm fastapi poetry install
-
Setup Static Files
docker-compose run --rm fastapi poetry run python manage.py collectstatic --noinput
-
Migrate
docker-compose run --rm fastapi poetry run python manage.py migrate
-
Create Super User for Admin Page
docker-compose run --rm fastapi poetry run python manage.py createsuperuser
-
Start Server
docker-compose up
alias for frequently used commands
source alias.sh