Skip to content
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

[RFC] Add dotenv loader to allow multiple dotenv files #753

Open
mazlum opened this issue May 16, 2022 · 2 comments
Open

[RFC] Add dotenv loader to allow multiple dotenv files #753

mazlum opened this issue May 16, 2022 · 2 comments
Milestone

Comments

@mazlum
Copy link

mazlum commented May 16, 2022

I love dynaconf. It doesn't support multiple dotenv. I think it should support multiple dotenv.

for example;

settings = Dynaconf(
    dotnev_path=[str(BASE_DIR / "envs")],
    settings_files=[".env", ".secret.env"],
)
@rochacbruno
Copy link
Member

I think it is a good idea to add a .env loader to handle .env extension files.

The workaround for it is

from dynaconf import Dynaconf
from dynaconf.utils.parse_conf import parse_conf_data
from dynaconf.vendor.dotenv import dotenv_values

envvar_prefix = "MYAPP"
settings = Dynaconf(envvar_prefix=envvar_prefix)

data = {
        k[len(envvar_prefix):]: parse_conf_data(v, tomlfy=True, box_settings=settings)
        for k, v in dotenv_values(".secret.env").items()
        if k.startswith(envvar_prefix)
}

settings.update(data)

@rochacbruno rochacbruno added this to the 3.2.0 milestone Jun 1, 2022
@mazlum
Copy link
Author

mazlum commented Jun 1, 2022

Thank you @rochacbruno. It looks good, i will try. And maybe i can open pr about it.

@rochacbruno rochacbruno changed the title multiple dotenv [RFC] Add dotenv loader to allow multiple dotenv files Sep 21, 2022
@rochacbruno rochacbruno modified the milestones: 3.2.0, 4.0.0 Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants