Skip to main content

A configurable way of moving some settings out of the django and into a deployable .ini file

Project description

# django-ini-settings

This library aims to be a non-intrusive configurable way of moving some local
settings out of the django and into a deployable .ini file

## Quick-start

Install this library

pip install django_ini_settings

Add the hook into your, if you want to use the default config
mapping the following would do:

from django_ini_settings.load import load_ini


This implies that your ini file is located in /etc/application/application.ini
For example this ini might look like:

user = postgres
password = secret

secret_key = !sfgr42325asdasd$34324
debug = false

To insert custom configs you can either use the default format of the type as the group
and the config name as the option. e.g.

custom_url = /custom/url

feature_on = false

max_num_files = 120

This would be transformed to the following in your

CUSTOM_URL = "/custom/url"

You can also provide your own mapping, including wildcards. e.g. add the
following in your settings

from django_ini_settings.load import load_ini
from django_ini_settings.settings_types import (DictItemSetting, StringSetting,
BoolSetting, IntSetting)
from django_ini_settings.statics import ANY, NAME_TO_UPPER

("database", "user"): DictItemSetting(("DATABASES", "default", "USER")),
("database", "password"): DictItemSetting(("DATABASES", "default", "PASSWORD")),
("database", "engine"): DictItemSetting(("DATABASES", "default", "ENGINE")),
("database", "name"): DictItemSetting(("DATABASES", "default", "NAME")),
("database", "host"): DictItemSetting(("DATABASES", "default", "HOST")),
("database", "port"): DictItemSetting(("DATABASES", "default", "PORT")),
("security", "secret_key"): StringSetting("SECRET_KEY"),
("security", "debug"): BoolSetting("DEBUG"),
("urls", "media_url"): StringSetting("MEDIA_URL"),
("urls", "static_url"): StringSetting("STATIC_URL"),
("application", "max_file_size"): IntSetting("MAX_FILE_SIZE"),
("application", ANY): StringSetting(NAME_TO_UPPER),


## Environment Variables

Instead of doing:


You can also set an environment variable "DJANGO_CONFIG_FILE" containing the location of
the INI file. e.g.


Then change the line to:


## Tests

To run the tests, first make sure you have nose. If not then:

pip install nose

If you have nose installed then from the same directory as this README:


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django_ini_settings, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size django_ini_settings-0.1.0.tar.gz (4.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page