Skip to main content

Django settings using TOML configuration files.

Project description

This project is used to configure Django projects using a Toml configuration file. This project chooses Toml over other configuration language becuase of it’s simplicity and small specification. It is easier to understand and looks very much like INI-style config. We couldn’t use INI-style because it is difficult to repsent data structures like dictionaries and lists, and there is no support for nesting.



  • Add support for Substitution in maps and lists.

  • Fix loading settings where values are non-string which caused TypeError in v0.0.3.


  • Fix packaging for the new release.


  • Add support for variable substitution using ${VAR} syntax in values.


To use this in your Django project, Add the following to your file:

from django_settings_toml import load_settings

load_settings(__name__, ['/etc/project.toml', '~/.project.toml'])

Then, you can run your django project like this:

$ DJANGO_SETTINGS_MODULE=project.settings django-admin runserver

Variable Substitution

Values can refer to other keys defined in the same file using ${VAR} syntax. For example:

# /etc/project.toml

HOSTNAME = 'domain.local'

EMAIL1 = 'aperson@${HOSTNAME}'

EMAIL2 = 'bperson@${HOSTNAME}'

In the above example, the value of EMAIL1 = 'aperson@domain.local and similar for EMAIL2.

If they variables that are being referred to aren’t defined, the template is left as-is and doesn’t raise any errors. For example, in the above example, if HOSTNAME wasn’t defined, the value will be EMAIL1 = 'aperson@${HOSTNAME}.

Example Settings

# /etc/project.toml
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'change-this-on-your-production-server'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = false

['Mailman Suite Admin', 'root@localhost'],

# Application definition


ROOT_URLCONF = 'project.urls'

WSGI_APPLICATION = 'project.wsgi.application'

HOSTNAME = 'project.local'

EMAIL_NAME = 'project1@${HOSTNAME}'

ENGINE = 'django.db.backends.sqlite3'
NAME = 'mailmansuite.db'

version = 1
disable_existing_loggers = false

'()' = 'django.utils.log.RequireDebugFalse'

level = 'ERROR'
filters = ['require_debug_false']
class =  'django.utils.log.AdminEmailHandler'

level = 'INFO'
class = 'logging.handlers.WatchedFileHandler'
filename =  'logs/mailmansuite.log'
formatter = 'verbose'

handlers = ['mail_admins', 'file']
level = 'ERROR'
propagate = true

format = '%(levelname)s %(asctime)s %(process)d %(name)s %(message)s'


  • Please make sure that you have writtena valid Toml, you can use TOML Validator or tomlcheck tools to validate the toml file.

  • Please make sure that all smiple KEY = value pairs are in the root namespace (above any [section]) so that they don’t get swallowed under one of the maps or arrays. Previously, we have seen ImproperlyConfiguredError for missing keys that were actually defined in the toml file.


The contents of this project is licensed under Apache License 2.0. Please see the LICENSE file for a complete copy of license text.

Project details

Download files

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

Source Distribution

django-settings-toml-0.0.4.tar.gz (9.3 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page