Allow for more complex and dynamic settings for Django
Project description
django-enhanced-settings
Allow for more complex and dynamic settings for Django.
Extras
cloud-secret-manager
- Adds support for Google Cloud Secret Manager
Example
import os
from django_enhanced_settings import Settings
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
settings = Settings(BASE_DIR)
def __dir__():
return settings.dir(globals())
def __getattr__(name):
return settings.getattr(name, globals())
_DEBUG = settings.boolean_value('DJANGO_DEBUG', False)
_ALLOWED_HOSTS = settings.list_value(
'DJANGO_ALLOWED_HOSTS',
['localhost'] if _DEBUG.value else [],
split_char=';'
)
_SECRET_KEY = settings.string_value('DJANGO_SECRET_KEY', required=True)
INSTALLED_APPS = [...]
from django.conf import setings
settings.DEBUG # By default returns False
Rules
- You are not allowed to name a non
ConfigValue
using the naming scheme set for theSettings
instance (suffix_underscore
). For example, writing the following would raise aValueError
in the above example:
_INSTALLED_APPS = [...]
- You are not allowed to name a
ConfigValue
without using the naming scheme set for theSettings
instance (suffix_underscore
). For example, writing the following would raise aValueError
in the above example:
SECRET_KEY = settings.string_value('DJANGO_SECRET_KEY', required=True)
- You are not allowed to define 2 variable names that result in the same accessible name. For example, writing the following would raise a
ValueError
in the above example:
_SECRET_KEY = settings.string_value('DJANGO_SECRET_KEY', required=True)
SECRET_KEY = 'SECRET_KEY'
If you would like to customise these rules you can write your own __dir__
and __getattr__
.
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
Built Distribution
Close
Hashes for django-enhanced-settings-0.2.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c58e321526ad637956579c6dffcf921ed41dedbce3b2cfe6582abf17f71965a9 |
|
MD5 | 581404b1d6f9bcd8df0b913d352eb583 |
|
BLAKE2b-256 | bb6f30a3ad97f277850b764bd14d945bc00a95bca1d22151d56771378d8e5a8b |
Close
Hashes for django_enhanced_settings-0.2.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8a7a7e25eee033bb1b3012bb3d109a1199f778bb4e0a7726e62b7a217c39009 |
|
MD5 | 2cf6bd716499c8072e93244be071adf8 |
|
BLAKE2b-256 | ec3ba1cd29ccace3b0cb6268d57b364f6150c943432590a6a6f4e6aba55b24b7 |