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

Default and local env file #272

Closed
Saphyel opened this issue Aug 22, 2020 · 4 comments
Closed

Default and local env file #272

Saphyel opened this issue Aug 22, 2020 · 4 comments

Comments

@Saphyel
Copy link

Saphyel commented Aug 22, 2020

I was thinking it could be possible to make this module read the .env file but if you have .env.local or maybe .env.local or other files they will be loaded on top.
The advantages of this approach are:

  • You can commit in your project .env file

  • In scenarios where you can not change the .env file or the env. vars. you have the flexibility to add a new file and will be loaded on top.

  • Your production code will be like your local.

The only disadvantage I can think of is

  • A small logic needs to be implemented.
@bbc2
Copy link
Collaborator

bbc2 commented Aug 25, 2020

We've seen similar feature requests in the past, regarding multiple scenarios. Please have a look at #73 for a previous discussion. Does it look like it could solve your issue?

@Saphyel
Copy link
Author

Saphyel commented Aug 25, 2020

@bbc2 thanks for the comment but it's not what I request (but similar!)

    dotenv_file_list = []
    for file in os.listdir("./"):
        if file.startswith(".env"):
            dotenv_file_list.append(file)
    load_dotenv_files(dotenv_file_list)

@bbc2
Copy link
Collaborator

bbc2 commented Aug 25, 2020

I think that with some code like the following, your program should work as you want:

for file in dotenv_file_list:
    load_dotenv(file)

We're not likely to implement this logic in Python-dotenv itself because there are too many different use cases requested by users.

@bbc2
Copy link
Collaborator

bbc2 commented Feb 21, 2021

I'm closing this issue because there doesn't seem anything we'll in python-dotenv with regards to this issue.

@bbc2 bbc2 closed this as completed Feb 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants