Skip to main content

Organize Django settings into multiple files and directories. Easily override and modify settings. Use wildcards and optional settings files.

Project description

https://github.com/sobolevn/django-split-settings/blob/master/media/logo-black.png?raw=true
https://travis-ci.org/sobolevn/django-split-settings.svg?branch=master https://coveralls.io/repos/github/sobolevn/django-split-settings/badge.svg?branch=master https://badge.fury.io/py/django-split-settings.svg https://img.shields.io/pypi/pyversions/django-split-settings.svg https://readthedocs.org/projects/django-split-settings/badge/?version=latest

Organize Django settings into multiple files and directories. Easily override and modify settings. Use wildcards in settings file paths and mark settings files as optional.

Read this medium post for more information.

Requirements

While this package will most likely work with the most versions of django, we do not officially support any versions except the latest release and the current LTS version, which are 1.11 and 2.0 right now.

This package has no dependencies itself.

Installation

Install by using pip:

pip install django-split-settings

We also recommend to try pipenv to handle dependencies.

Usage

Replace your existing settings.py with a list of components that make up your Django settings. Preferably create a settings package that contains all the files.

Here’s a minimal example:

from split_settings.tools import optional, include

include(
    'components/base.py',
    'components/database.py',
    optional('local_settings.py')
)

In the example, the files base.py and database.py are included in that order from the subdirectory called components/. local_settings.py in the same directory is included if it exists.

Note: The local context is passed on to each file, so each following file can access and modify the settings declared in the previous files.

We also made a in-depth tutorial.

Tips and tricks

You can use wildcards in file paths:

include('components/my_app/*.py')

Note that files are included in the order that glob returns them, probably in the same order as what ls -U would list them. The files are NOT in alphabetical order.

Do you want to contribute?

Read the contributing file.

Version history

See changelog file.

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-split-settings-0.3.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

django_split_settings-0.3.0-py2.py3-none-any.whl (6.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-split-settings-0.3.0.tar.gz.

File metadata

File hashes

Hashes for django-split-settings-0.3.0.tar.gz
Algorithm Hash digest
SHA256 04f6b551111fdbcb4f669ac9004ac2d4a27197a36ca88444cb896378807ed777
MD5 cd358eb03b3a7d7d8ca76289cc0f5207
BLAKE2b-256 654f1c1fb4a219c6799a1003a824b67ac24fd92a091b686708d342c93c19d4c5

See more details on using hashes here.

File details

Details for the file django_split_settings-0.3.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_split_settings-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 14b164dbd724e52aa9a0b0338eefa988a8a0f17f7cba34e0f983e5348682aeb7
MD5 c7c445398db7aebdc05420f36ca9d6b8
BLAKE2b-256 dab538b620288c2c041af6eb336fb5bf1d2572c8d92d63a255c2d99e1516f171

See more details on using hashes here.

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