/fastapi-django-template

FastAPI with Django ORM and Admin.

Primary LanguagePython

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.

  1. https://python-poetry.org/docs/#installation
  2. python -m venv venv
  3. source venv/bin/activate
  4. pip install --upgrade pip (if needed)
  5. 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.

  1. https://pre-commit.com/#installation
  2. pre-commit install

Usage

  1. Clone this repository

     git clone https://github.com/kathmandu777/fastapi-django-template.git
  2. Create fastapi.env with reference to fastapi.env.tmpl

  3. Build

    docker-compose build
  4. Dependency install

    docker-compose run --rm fastapi poetry install
  5. Setup Static Files

    docker-compose run --rm fastapi poetry run python manage.py collectstatic --noinput
  6. Migrate

    docker-compose run --rm fastapi poetry run python manage.py migrate
  7. Create Super User for Admin Page

    docker-compose run --rm fastapi poetry run python manage.py createsuperuser
  8. Start Server

    docker-compose up

alias for frequently used commands

source alias.sh