It’s 2025 man, and I’m starting a new Django project. There’s a billion options for management. I want
- linux
- uv (instead of poetry)
- vscode
- secrets in .env
- podman or docker for redis and postgres
- boilerplate with all-auth, custom user, etc
I choose to use:
Recipe:
# get boilerplate - excessive for simple projects but whatevers
cookiecutter gh:cookiecutter/cookiecutter-django # answer questions
cd <project>
# convert to pyproject.toml (instead of requirements.txt)
uv add -r requirements/base.txt
uv add -r requirements/local.txt --dev
rm -rf requirements
#
Environment
Create .env with variable and secrets,
Caller (e.g. uv, systemd, vscode), not code, is responsible for loading environment.
Use direnv for your command line, but don’t rely on it for tools (e.g. vscode should load .env itself). Ensure you export the variables, don’t just source them:
# .envrc
set -a # auto export vars
source .env
set +a
Settings
CookieCutter uses base.py, then “local.py”, etc. That’s fine. I tweak things:
- remove loading of Environ
- use os.environ[“MY_VAR”] to fast fail if env var not there
- simplify / remove unused settings
Postgres and Redis in Container
services:
db:
image: postgres:17
container_name: basixbot-postgres
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
ports:
# host:container — change 5439 to whatever host port you want
- ${PGHOST_PORT}:5432
volumes:
- pgdata:/var/lib/postgresql/data
restart: unless-stopped
redis:
image: redis:7
container_name: basixbot-redis
# ports:
# # host:container — change 6381 to whatever host port you want
# - 6381:6379
restart: unless-stopped
volumes:
pgdata:
Webpack
npm install
npm run build # writes to project/app/static/webpack_bundles/css|js