Django
Project bootstrap and the management commands used most.
pip install django djangorestframework mysqlclient django-storages \
google-cloud-storage django-cors-headers python-dotenv
django-admin startproject config .
python manage.py startapp core apps/core
python manage.py startapp api apps/api
Day to day
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver
python manage.py check
Inside a container, prefix with docker compose exec web — see
Docker Compose.
Static files
npm run build && python manage.py collectstatic --noinput
npm run build && python manage.py collectstatic --clear --noinput
Linking python to python3
sudo apt install -y python-is-python3
Prefer the package over ln -s /usr/bin/python3 /usr/bin/python: a hand-made
symlink in /usr/bin is unmanaged, survives upgrades that move the target, and
conflicts with the package if it is ever installed.
Environment
DEBUG = false
DB_USER = admin
DB_HOST = db
Keep .env out of the image and out of version control; inject it at deploy
time.