Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Django template for Docker + Heroku

This is how I set up Django projects to get up and running as quick as possible. In includes a few neat things:

Getting started

To get started (replace myapp with the name of your app):

$ docker run -it --rm -v "$PWD":/usr/src/app -w /usr/src/app django startproject --template --name .gitignore,.dockerignore,Dockerfile,,app.json,package.json,script/clean,.vscode/settings.json myapp
$ cd myapp
$ chmod +x ./ script/*

This readme file is now in your app's directory. You can delete this top bit and everything that follows is the start of your app's readme.

{{ project_name }}

Development environment

Install Docker, then run:

$ docker-compose up --build

This will boot up everything that your app needs to run.

(Note: the --build argument is not required, but will ensure the Python and JS dependencies are always up-to-date.)

In another console, run these commands to set up the database and set up a user:

$ docker-compose run web ./ migrate
$ docker-compose run web ./ createsuperuser

The local development environment is now running at http://localhost:8000. The admin interface is at http://localhost:8000/admin/, accessible with the user/pass created above.


To run the test suite:

$ docker-compose run web ./ test

Deployment on Heroku

This app is designed to be deployed on Heroku.

These commands, roughly, will get you set up with an app. Replace {{ project_name }}-production with a name for the app:

$ heroku update beta
$ heroku plugins:install @heroku-cli/plugin-manifest
$ heroku apps:create --manifest --no-remote --stack=container {{ project_name}}-production
$ heroku config:set -a {{ project_name }}-production SECRET_KEY=$(openssl rand -hex 64)

In the Heroku web UI, go to the app, then the "Deploy" tab, then connect it to a GitHub repo. Then, click "Deploy branch" at the bottom to trigger a deploy. ./ migrate will be run on deploy.

On this page, you can also set up automatic deploys if you want. You probably want to check "Wait for CI to pass before deploy".

Static assets

CSS and JS goes in the assets/ directory. These are compiled by esbuild and postcss into {{ project_name }}/static/dist. You can write any modern JS that esbuild supports -- ES6, JSX, etc.

In development, Docker Compose runs a Parcel daemon alongside your Django development server to compile assets live. For production, Parcel is run in Dockerfile to bake the compiled assets into the production artifact.


Get a Django app up and running in dev, test, and production with best practices in 10 minutes






No releases published


No packages published