Django composable settings loader
Aims to compose your settings from python modules and python scripts in /etc.
In your my_app/settings/__init__.py call the loader:
from django_compose_settings import modules_loader locals().update(modules_loader(prefix='my_app', default='base,etc,post'))
In my_app/settings/base.py define default values as usual, ex:
import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # ...
In my_app/settings/etc.py call the etc loader:
from django_compose_settings import etc_loader locals().update(etc_loader(prefix='my_app'))
You can validate settings in my_app/settings/post.py as follow:
import __settings__ assert hasattr(__settings__, 'BASE_DIR'), 'BASE_DIR required'
Etc settings
Here is a sample tree of your /etc/my_app:
/etc/my_app/ ├── settings.d │ ├── 00_prod1.py │ └── 99_local.py └── settings.py
Each .py file is a regular composable settings file as post.py above.
MY_APP_SETTINGS
You can override your settings with a specific SETTINGS environment variable for your app as follow:
$ MY_APP_SETTINGS=base,post python
>>> import logging
>>> logging.basicConfig(
... level=logging.INFO,
... format='%(asctime)s %(levelname)-8s %(name)s %(message)s'
... )
>>> import os
>>> import sys
>>> sys.path.append(os.path.join(os.path.abspath('tests'), 'fixtures'))
>>> from my_app import settings
2015-11-23 10:59:09,964 INFO django_compose_settings Loaded my_app.settings.base
2015-11-23 10:59:09,964 INFO django_compose_settings Loaded my_app.settings.post
Metadata
Release files for django-compose-settings 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-compose-settings-0.4.tar.gz | 4.9 kB | Without provenance | Details for django-compose-settings-0.4.tar.gz |
Release files / django-compose-settings-0.4.tar.gz
| Download URL | django-compose-settings-0.4.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7afd28aec95d6d9229842a17f0aed5c280b3c25af158168846e215381b004802
|
|
BLAKE2b-256 checksum How to use checksums |
00d8faa9c24322b81940b2f6d05bc4618647e858a849d558799d0378cbfdbeb4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.1
|
Security for django-compose-settings 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.