Using Docker

If you want to try out the django-base-site using Docker then you first need to install docker. Then you can go through the following steps.

  1. First download the django-base-site wherever you want your new project.
$ TARGET_DIR=~/Sites/ BRANCH=master PROJECT_NAME=example && \
cd $TARGET_DIR && \
curl -L "$" | tar zx -C $TARGET_DIR && mv "django-base-site-$BRANCH" $PROJECT_NAME &&  \
  1. Create your .env file.
$ export SECRET_KEY=$(python -c "import random; print(''.join(random.SystemRandom().choice('abcdefghijklmnopqrstuvwxyz0123456789%^&*(-_=+)') for i in range(50)))") && \
cat > .env <<EOF
DEFAULT_FROM_EMAIL="President Skroob <>"
  1. Build your service images.
$ docker-compose build
  1. Run migrations and Create a super user.
$ docker-compose run web python migrate && \
docker-compose run web python createsuperuser
  1. Run the Django runserver.
$ docker-compose up



Set a trace like you normally do in your code and then go to that view in your browser and then stop docker-compose up.

import ipdb; ipdb.set_trace()

Then you can run the following to work interactive debugging shell.

docker-compose run --service-ports web


Running Gulp

  • When you run docker-compose up it starts the node service which should run gulp.
  • If you want to run gulp by itself, you can run it with a command like, docker-compose run --rm node.

Common Gotchas

  • You need to start your runserver using docker-compose up instead of docker-compose run web python runserver or you won’t be able to access your site from your browser.
  • Installing django-debug-toolbar can ignore the Django version you’ve specified in your Pipfile and instead Django 2 because django-debug-toolbar uses “Django” with a capital D in it’s requirements when other packages use “django” in lowercase. To work around this install everything except django-debug-toolbar and then added it last to your Pipfile.

Common Commands

Command Description
docker-compose up Starts up all of your services according to how they were defined in your docker-compose.yml file.
docker-compose down Stops containers and removes containers, networks, volumes, and images created by up.
docker volume ls List the volumes that have been created