$ python -c 'import secrets;print(secrets.token_urlsafe(48))'
# Output:
<YOUR_SECRET_KEY>
# .env
DEBUG=True
SECRET_KEY=<YOUR_SECRET_KEY>
DB_USER=<YOUR_DB_USERNAME>
DB_PASS=<YOUR_DB_PASSWORD>
DB_NAME=ahs_dev
DB_HOST=
DB_PORT=
DJANGO_SETTINGS_MODULE='adminpanel.settings'
DB_BACKUP_ON_SHUTDOWN=1
DB_RESTORE_ON_START=0
- leave DB_HOST & DB_PORT empty to connect django & postgres container over a UNIX socket connection.
- both containers mount the same volume which is mapped to UNIX socket parent dir
- IDE or Database Tool connects to postgresql DB on localhost:5433.
docker compose \
--env-file /path/to/adminpanel/.env \
-f /path/to/adminpanel/docker-compose-dev.yaml \
-p adminpanel up \
-d \
--build
# start a terminal in django docker container and create adminpanel admin user
user@django:/project$ python manage.py createsuperuser
# Output:
Username: ...
Email Address: ...
...