Skip to content

Python Django + PostgreSQL

Edward Baitsewe edited this page Feb 25, 2025 · 3 revisions

You could use this example app as a base for your new project or as a guide to Dockerize your existing Django app.

The example app is minimal but it wires up a number of things you might use in a real world Django app, but at the same time it's not loaded up with a million personal opinions.

This app is using Django 5.1.6 and Python 3.13.2. The screenshot doesn't get updated every time I bump the versions:

What Django Docker Guides Wrong

Most guides get dockerising your Django project wrong in three ways:

1. Using runserver Command in Production

This command is not intended is not intended ot be used in production. You lose out on a lot of performance. To solve this use Gunicorn.

2. Guides Completely Ignore Serving Static Files

Many guides leave you with a broken product, where the CSS isn't loading in.

3. Django-admin Breaks

Django admin doesn't work most of the time with CSS and other static asses not loading.

Notable opinions and extensions

Django is an opinionated framework and I've added a few extra opinions. Here's a few (but not all) note worthy additions and changes.

Install the packages.

pipenv install gunicorn whitenoise

Install development dependencies.

pipenv install django-debug-toolbar --dev

Configure Gunicorn

Configure White Noise

See the documentation for White Noise

Run pip freeze

pipenv pip freeze > requirements.txt

Acknowledgements

A list of resources that I found helpful.

Clone this wiki locally