- Pre-written Dockerfile
- Pre-setted Docker-Compose
- PostgreSQL Database (also for test db)
- Nginx
- WAS (Django)
- Ready-to-production
- Required packages are already added to dependencies
- Mypy
- Django-stubs
- Poetry
- Pytest
- Django
- DRF
- Document generator: DRF-Spectacular
- ETC ...
- Seperated settings file
- Seperated user apps into
apps/
directory - Seperated
urls.py
intobackend/
directory andapi/
directory
- Required packages are already added to dependencies
- python3.9
- poetry
- docker
- docker-compose
poetry install
docker compose up -d db test_db
poetry shell
python3 manage.py runserver 0.0.0.0:8000
Create a file named .env
and fill following fields:
DJANGO_SECRET_KEY=your secret key
DJANGO_SETTINGS_MODULE=your settings module name
# following values are optional
PROD_DB_NAME=your production database name
PROD_DB_USER=your production database user
PROD_DB_PASSWORD=your production database password
PROD_DB_HOST=your production database host
docker-compose up -d --build db was ws
The reason is that we haven't defined our image's version.
In this case, deleting the image that we build can be the answer, like:
docker image rm drf-psql-template_was
Now you can build your application, like above chapter.
docker-compose up --build test_db
pytest -vvk .
First of all, let's create our app by executing following commands:
python3 manage.py startapp "appname"
mv "appname" apps
Since we have seperated our own apps into apps
directory, we have to change our app's name from appname/apps.py
.
Change like following:
from django.apps import AppConfig
class AppnameConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'apps.appname'
Make sure you have changed appname
into your real app name.
Or you can simply edit the name
variable from your AppnameConfig
class.
Now it's time to register our app into the settings.
Open backend/settings/base.py
and add your app's name like:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# 3rd party
'rest_framework',
'drf_spectacular',
# my apps
'apps.appname',
]
- Setup CI / CD
- Add plugins to repository like codecov
- ETC ...