-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Cascaded settings files #142
Comments
I don't think that multiple files make sense for python-decouple. One of the main ideas of the lib is to avoid multiple settings files by reading variables from the environment. If you really need this multiple files behavior, you can try implementing an extension as described in #115. |
What if I have 3 environments? A
I wish I could have:
And |
In the
In the
In the
|
Here's what I'm using to cascade multiple repositories: from decouple import Config, RepositoryEnv, RepositoryEmpty
class RepositoryComp(RepositoryEmpty):
def __init__(self, *repositories):
self.repositories = repositories
def __getitem__(self, key):
for repository in self.repositories:
if repository.__contains__(key):
return repository[key]
raise KeyError(key)
def __contains__(self, key):
for repository in self.repositories:
if repository.__contains__(key):
return True
return False
config = Config(RepositoryComp(RepositoryEnv('.private.env'), RepositoryEnv('.env'))) |
Hey @b0o. This is cool. I wonder if using a
|
@henriquebastos That does work with
[settings]
FOO=Hello
[settings]
BAR=Goodbye
If
|
Enables RepositoryIni to be used in a collections.ChainMap to allow cascading multiple repositories. See HBNetwork#142
Great work, @b0o! Thank you. |
After multiple attempts this works. Putting the overriding configs before the default configs.
|
Hi,
I am running Django with multiple tenants. For each tenant I am using a different settings.ini file. But each of this files has common parameters like e.g. DB credentials.
In order to only maintain these kind of common parameters only once I would like to have one common-settings.ini file beside the tenant specific settings.ini files. The settings.py is stored in GIT and therefore cannot save credentials. Would it be possible to read more than one settings file?
Thanks
The text was updated successfully, but these errors were encountered: