Skip to content
Providing settings with default values in Django applications.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Default Settings for Django Applications

version: 0.2

This repository [1] contains a proof of concept Django application that ships default values for its own settings. This is good for a number of reasons:

1. The application's settings are included in the output of diffsettings.

2. Application code can just use settings.MY_SETTING instead of getattr(settings, 'MY_SETTING', 'The default value').

3. Application settings are defined in a single place, with sane default values and, hopefully, with comments. Don't Repeat Yourself!

The actual code is rather simple: it just uses the opportunity afforded it when the application module is loaded to inject its own default settings into both the django.conf.global_settings module (Django's built-in default settings, and the source for things like the diffsettings management command) and the django.conf.settings object (being careful to check to see if it already contains a value).

To see more, take a look at:

This is slightly less than a perfect solution (being able to patch django.conf.global_settings before django.conf.settings is initialised), but the hypothetical perfection is simply not possible: the settings must be loaded before they can be used to import the INSTALLED_APPS.


pip install django-application-settings

or latest:

git clone
cd django-application-settings
python install

Although this repository is so simple that between git repository and pip package will be delay few day at most (probably hours).


The simplest method is to use autodiscover_settings somewhere in


Or you can add these lines to inside your app if you don't want to load settings from other packages in INSTALLED_APPS:

from application_settings import provide_default_settings

Create file inside your application directory with default settings:

# Example
PREFIX_KEY = 'value'

It's advisable to use PREFIX before all your settings names to avoid names clash.

[1]See original repository.
You can’t perform that action at this time.