No project description provided
Project description
envsettings
- Update django settings from environment variables by updating
sys.modules
- Mostly using
ast.literal_eval
to convert string to python object. - Tested by converting all default django settings to string and back to python object and then running django command.
todo
- simplify code
- verify settings after they are casted to python object
- Usage:
- in
myproject.settings
:import os import sys import ast from djangobuk_envsettings import update_from_env update_from_env( sys.modules[__name__], # default prefix for all variables pre='DJANGO_', # settings that can be updated from env # by default all settings are allowed (this option overrides) allowed=[ 'SECRET_KEY', 'SITE_ID', ], # optional # extra settings and their types (to be used with extra_allowed) extra_mapping={ 'DATABASE_PATH': ast.literal_eval, }, # optional # extra settings that can be updated from env extra_allowed=[ 'DATABASE_PATH', ] ) # nothing more required DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': DATABASE_PATH, } }
- in
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
Close
Hashes for djangobuk_envsettings-0.3.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a74c4719e31798edf7b1063c605e0b098f18adff617e91ae990b9ed8d4965207 |
|
MD5 | 9708e87b9e1aa236c6d2271e5b04ccc1 |
|
BLAKE2b-256 | 9a621bf7cff353a1c95034a4c85a491e6fe54e5e0924e88de0c37ed2a21f9d71 |