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.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4cf448ab15e887cddfe0c8b6b5098d0e70a117077eba7dcc240b83d3e77b3b0 |
|
MD5 | 60af58f5ba44e4168055ad05003d0427 |
|
BLAKE2b-256 | 40a3442f0d868962d63a257121b7a65a71a3700080bcb5e7d6fdfee983df2a4e |
Close
Hashes for django_enhanced_settings-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e719265de6316e9dcd0772071b2fd766c407319628a4280502171f44bea1cc8e |
|
MD5 | 1c7a1d31460db6367079626b41e8d43f |
|
BLAKE2b-256 | 9b7d14d46cee4246f6b2e75f563a06a077558c93113148cf01cd17eea62e29e6 |