Dynamic settings
leobuskin opened this issue · 2 comments
leobuskin commented
Nice solution, but couldn't find best practice how to use settings from one component within another one. For example, we have components\django.py
that uses some variables from components\common.py
, is it safety to do an import? How you organizing it? I wasn't able to find such samples in tests.
sobolevn commented
Thanks for interest!
That's how I do it.
# server/settings/components/common.py
SOME_VALUE = ('setting', )
# server/settings/components/other.py
from server.settings.components.common import SOME_VALUE
SOME_VALUE += ('other', )
OTHER_VALUE = 123
And importing all components:
# server/settings/__init__.py
from split_settings.tools import optional, include
include(
'components/common.py',
'components/other.py',
)
# SOME_VALUE will be equal to ('setting', 'other', )
leobuskin commented
Perfect, thanks for the quick reply, works like a charm. We just switched to your package mostly all products and twice happier than before.