Settings Manager
This project provides a simple and extensible strategy for managing Django settings.
Settings file format
There are three main sections:
- configure - This is intended to be set up before most processing in settings.py, and should mostly be used to enable/disable built-in features. For example, settings.py might configure remote user auth if ENABLE_REMOTE_USER_AUTH is true.
- override - This is used to override settings.py. Use this section for database settings and other more complex configurations that are environment specific.
- inject - This is used to override values using one of the built-in fuctions, or any user-defined function that is made available.
Example settings.py file
import sys
import os
from settings_manager import SettingsManager
settings_manager = SettingsManager(os.environ.get("DJANGO_SETTINGS_FILE", "/etc/django-settings.yaml"))
# Defaults for configurable items
ENABLE_REMOTE_USER_AUTH = False
ENABLE_MODEL_AUTH = False
# Configure settings manager
settings_manager.configure(sys.modules[__name__])
# Set the module's base directory
BASE_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.ModelBackend' if ENABLE_MODEL_AUTH else None,
'shibboleth.backends.ShibbolethRemoteUserBackend' if ENABLE_REMOTE_USER_AUTH else None,
]
# ... other configuration ...
# Rebuild AUTHENTICATION_BACKENDS to remove null values
AUTHENTICATION_BACKENDS = [m for m in AUTHENTICATION_BACKENDS if m is not None]
settings_manager.override(sys.modules[__name__])
Sample configuration (YAML) file
inject:
DATABASES.default.password:
function: get_env
args: [DJANGO_DATABASE_PASSWORD]
DEBUG:
function: get_env
args: [DJANGO_DEBUG]
value_processors:
- function: str_to_bool
args: ['<<value>>']
configure:
ENABLE_REMOTE_USER_AUTH: true
override:
DATABASES:
default:
username: django
name: django
host: db
port: 5432
password: ~ # will be replaced by injected value.
Metadata
Release files for django-settings-manager 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-settings-manager-0.0.4.tar.gz | 3.5 kB | Without provenance | Details for django-settings-manager-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_settings_manager-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for django_settings_manager-0.0.4-py3-none-any.whl |
Total release size: 7.8 kB
Release files / django-settings-manager-0.0.4.tar.gz
| Download URL | django-settings-manager-0.0.4.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f96eb77c54b327a42054a52f87e574a113dccf78be6a7e52517d846d8bd40144
|
|
BLAKE2b-256 checksum How to use checksums |
3f18d210585b3a6425a4e3110042c4c3fae0b12216a73d7e5d02b916b0bd16bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.2
|
Release files / django_settings_manager-0.0.4-py3-none-any.whl
| Download URL | django_settings_manager-0.0.4-py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9ff7bd1b2e949221908026ca76df112db0807448e7cf1595005fed93a5da720c
|
|
BLAKE2b-256 checksum How to use checksums |
1d7e52a46adc1c999a597a8580fa44ec42e65e10f5b49b3dd136278c24073b99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.2
|
Security for django-settings-manager 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.