Columbia CTL common Django base settings

pip install ccnmtlsettings==1.9.4


Actions Status

These are the common settings we use across all our Django apps, extracted into a handy reusable module.



First, install it with

$ pip install ccnmtlsettings

or add ccnmtlsettings==0.1.0 to your requirements.txt.


The following libraries are used in some way, so they'll need to be installed:

  • django_compressor
  • django-debug-toolbar
  • coverage
  • django-smoketest
  • django-extensions
  • django-statsd-mozilla
  • django-markwhat
  • django-storages
  • django-impersonate
  • boto3
  • sentry-sdk
  • statsd
  • gunicorn
  • djangowind

Use it

ccnmtlsettings has three "environments" (for now) that you will want to make use of: shared, staging, and production.

In your you will want to do something like:

import os.path
from ccnmtlsettings.shared import common

project = 'yourapp'
base = os.path.dirname(__file__)

locals().update(common(project=project, base=base))

# which apps should jenkins include in coverage reports?

INSTALLED_APPS += [  # noqa

Most of the magic is on the locals().update(...) line. That's where the common function from ccnmtlsettings.shared is called with simple configuration and returns a bunch of variables, which are then injected into the local symbol table. The two requires parameters are project and base.

project is the name of your project. It should be lowercase with just alphanumeric characters. Most likely, just the name of the directory for your project.

base is the full path of the directory that is in.

After that, a few settings that ccnmtlsettings can't fully set up are set and/or modified. In particular, the project's apps are added to INSTALLED_APPS.

An important note is that because of the weird symbol table tweaking done earlier, flake8 will complain if you try to modify a variable that comes out of ccnmtlsettings, since it didn't see where it got defined. You need to add the # noqa line to each variable that you modify this way to get it to ignore it.

You'll do almost the same thing for your and

from myapp.settings_shared import *
from ccnmtlsettings.staging import common
import os

project = 'yourapp'
base = os.path.dirname(__file__)


	from myapp.local_settings import *
except ImportError:

(and the same thing for, but with from ccnmtlsettings.production import common instead.)

Again, you are passing in project, and base. The staging/production settings also need to have access to STATIC_ROOT and INSTALLED_APPS, so those must be passed in.

Finally, there are a couple variables related to static file deployment that you may or may not want to set:

s3static is a boolean. It defaults to True and tells ccnmtlsettings that you are using S3 for serving static files. Mainly, you will want to set this to False if your application is not yet serving static files off S3.

cloudfront is a cloudfront id. If you pass it in, AWS Cloudfront will be used for the static files URLs.


If you're converting an existing app to ccnmtlsettings, which I recommend is:

  • install ccnmtlsettings and any libraries it requires
  • add the ccnmtlsettings related stuff to the top of your and set up the basic configuration, but leave all your settings in place after it (effectively overriding everything that ccnmtlsettings is pulling in).
  • pull up in a browser.
  • line by line, setting by setting, compare what you have in your with what ccnmtlsettings has for the same variable. Delete yours if they are the same. Otherwise leave yours in place (or append the differences if it's a list variable).
  • run your tests/flake8 each time.
  • do the same for staging/production.