This starter employs Django, Django Rest Framework, and PostgreSQL to construct a REST API with OpenAPI documentation, integrated with Docker, Docker Compose, and GitHub Actions.
- Django web application framework
- Postgresql database
- Github Actions. For automatic testing , linting and Deployment. In order to connect the github with docker hub, we need to add Docker Hub's
account name
andaccess token
into github repository secrets. - Test Driven Development. Write Test -> Run Test(fail) -> add Feature -> Run Test(Passes). base on
unittest
library and Django REST Framework test features. - Docker.
- Fix database race condition by customing Django management command
wait_for_db
. Django Docs management command
Docker
and Docker Hub account for pulling images for Python and Postgresql. Anonymous users vs authorized users rate limitsGithub Actions
for automatic linting and testing.(Need to set upDOCKERHUB_USER
andDOCKERHUB_TOKEN
in github secrets in order to pull images from Dock hub)Django
andDjango REST Framework
Postgresql
Psycopg2
, the postgresql database adaptor for python, requirs additional dependencies:build-base
,postgresql-dev
,musl-dev
,postgresql-client
flake8
for linting.Pillow
for image uploadingdrf-spectacular
for OPENAPI docs
# app is the name of service.
docker-compose run --rm app sh -c "flake8" #linting
docker-compose run --rm app sh -c "python manage.py test" #tesing
- Django>=4.0.1,<4.1
- djangorestframework>=3.13.1,<3.14
- psycopg2>=2.9.3,<2.10
- drf-spectacular>=0.22.1,<0.23
- Pillow>=9.1.0,<9.2
- uwsgi>=2.0.20,<2.1
- flake8>=4.0.1,<4.1
📦
├─ .dockerignore
├─ .env.sample
├─ .github
│ └─ workflows
│ └─ checks.yml.sample
├─ Dockerfile
├─ README.md
├─ docker-compose.yml
├─ requirements.dev.txt
├─ requirements.txt
├─ scripts
│ └─ run.sh
└─ src
├─ .flake8
├─ app
│ ├─ __init__.py
│ ├─ asgi.py
│ ├─ settings.py
│ ├─ urls.py
│ └─ wsgi.py
├─ core
│ ├─ __init__.py
│ ├─ admin.py
│ ├─ apps.py
│ ├─ management
│ │ ├─ __init__.py
│ │ └─ commands
│ │ ├─ __init__.py
│ │ └─ wait_for_db.py
│ ├─ migrations
│ │ └─ __init__.py
│ ├─ models.py
│ └─ tests
│ ├─ __init__.py
│ └─ test_commands.py
└─ manage.py
©generated by Project Tree Generator
A newly initiating Django project with custom Django management command wait_for_db
implemented and tested in core
folder. The core
will manage all the models used in this projects and custom admin site functionality.
- Test Driven Development. Create
tests
folders in each subredictory with every file starting file name withtest_
in order to manage all test functions.