Deploying your Ella application


This is another part of Ella tutorial, but the techniques and actions described here should work for any Django project/application out there.

Most of what is used here can be found in our django-base-project template.

So far in our tutorial we got to a state where we have a fully working application, on localhost that is. Since you probably won’t be running it from there, you need to move it to another server. The moving itself isn’t the problem, but managing different configurations ( and keeping your database in order (migrations) might prove challenging. I want to describe some of the techniques we use to help us manage multiple environments and, possibly, multiple projects using the same database.

So far we have everything in a single file, all the configuration options - those that we need to run our project as well as those that cope with our current environment specifically. To help with this we will split our ellablog.settings module into a package:

mkdir ellablog/settings
touch ellablog/settings/
mv ellablog/ ellablog/settings/

with containing:

from ellablog.settings.base import *

This didn’t help our problem, but it gave us some more room to organize things a bit better. Now let’s split the configuration into more parts:

  • is responsible for setting all the variables we need for our project to run, mainly INSTALLED_APPS, TEMPLATE_LOADERS, TEMPLATE_CONTEXT_PROCESSORS
  • will contain the configurable parts, mainly db and cache definitions, server and filesystem paths (MEDIA_ROOT, MEDIA_URL), SMTP settings, ...
  • won’t get committed to our VCS but, if present, will provide overrides specific to some environment (dev/test/production)
  • will actually do all the work, it will import all the submodules in the proper order (as listed) to assure correct values are being used

Just to provide some more extensibility, we will also add a simple mechanism that will allow us to store in a separate location (/etc/ella) on our server (that way it won’t get overwritten during every install). Also it will initiate python’s logging module, if any of the configuration files ask for it. So the final will look:

# logging init - this options should be overriden somewhere

# load base configuration for whole app
from ellablog.settings.base import *

# load some dev env configuration options
from ellablog.settings.config import *

# try to import some settings from /etc/
import sys
sys.path.insert(0, '/etc/ella')
    from ellablog_config import *
except ImportError:
del sys.path[0]

# load any settings for local development
    from ellablog.settings.local import *
except ImportError:

    import logging.config

Fixtures and custom commands

service app

Static files





south, on deploy

Table Of Contents

Previous topic

Enhancing templates

Next topic


This Page