October 12 2010 Tuesday at 03:56 AM

Blog Page's Article

standing problem in Django for a while now. It’s not one that can be fixed by a change to Django itself—in fact, Django is incredibly flexible when it comes to specifying settings, which has given developers room to experiment with a range of solutions. I think I’ve found one which works pretty well.

Begin by breaking your settings into two groups: common settings, anddeployment-specific settings. Common settings are defined in asettings.common sub-module, and may include:

  • Defaults for settings like DEBUGADMINSMANAGERS andCACHE_MIDDLEWARE_SECONDS. If not subsequently overridden, the values specified here will be used, so they should provide sensible defaults.

  • App installation and setup: INSTALLED_APPSMIDDLEWARE_CLASSES,ROOT_URLCONF and TEMPLATE_CONTEXT_PROCESSORS all fall under this category.

  • A basic logging setup. It’s good to define, but not install, several handlers—these can optionally be added to the root logger in the deployment-specific configuration. For example, in my common settings, I always do: