Setup the database and running the application

Update the database

Once the settings step is done, enter the following command to sync the database :

python migrate

If you meet some errors with this command, have a look at the MIGRATIONS from 0.10.x to 0.11.x:

If you are installing the project from scratch, do not forget to create a super user:

python createsuperuser

Start the application in development/local mode

python runserver

Now open your browser and go to to start using the application

Note, that if DEBUG Setting in the is set to DEBUG=False static files won’t be served automatically and you’ll need to setup a web server (e.g nginx or apache) to serve the statics files from the statics folder.

If you do wish to run locally with DEBUG=False and automatic static files served you’ll need to run

python runserver --insecure

This isn’t a settings recommended for production deployments. for production deployments please follow the guide provided in django docs

Start the application in production mode

  • Set DEBUG to False in
  • you need a HTTP server to be up and running with the following settings:

For exemple for a Nginx HTTP server, with the following settings are just focused on the access to the application where /home/sites/ is the path to the virtualenv

server {
    # ROOT website
    root  /home/sites/;

    location /static/ {
            root  /home/sites/;
            gzip  on;

    ## PROXY backend
    location / {
        proxy_next_upstream error timeout invalid_header;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header        X-Forwarded-Host $host;
        proxy_set_header        X-Forwarded-Proto $scheme;

  • then from the folder /home/sites/, run
python collectstatics

Setup gunicorn that will start the applications

From the path /home/sites/

create a file init.cfg containing:

NAME="th"                                      # Name of the application
DJANGODIR=/home/sites/      # Django project directory

USER=foxmask                                   # the user to run gunicorn as
GROUP=foxmask                                  # the group to run as
NUM_WORKERS=1                                  # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=th.settings             # which settings file should Django use
DJANGO_WSGI_MODULE=th.wsgi                     # WSGI module name


# HTTPS=on

# Activate the virtual environment
source ../bin/activate

change USER and GROUP to the user and group that fit your needs

create a gunicorn_start script

in the folder /home/sites/ put

source $(dirname $0)/init.cfg

echo "Starting Gunicorn for $NAME"

exec ../bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
  --name $NAME \
  --workers $NUM_WORKERS \
  --user=$USER --group=$GROUP \
  --log-level=$LOG_LEVEL \
  --bind=$IP:$PORT \
  --access-logfile $ACCESSFILE --error-logfile $ERRORFILE

then make the script runnable

chmod +x gunicorn_start