I’m working on a reusable django app, which I want to make configurable by GLOBAL VARIABLES in settings.py.
I want these to be optional so I’ve provided default values inside my app in a conf.py module, where I have the following:
GLOBAL_1 = "Def value for global 1"
GLOBAL_2 = "Def value for global 2"
GLOBAL_3 = "Def value for global 3"
try:
from settings import GLOBAL_1
except:
pass
try:
from settings import GLOBAL_2
except:
pass
...
So defaults can get overwritten by configuration in settings.py should they exist.
This method won’t scale for too many variables so I was wondering if there’s a less verbose way to do this. Maybe I should use eval()?
Thanks a lot!
1 Answer