-
-
Notifications
You must be signed in to change notification settings - Fork 317
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
can not override environment settings that already have value with a file #103
Comments
Got the exact same problem, and it turned me crazy to find why my code was not working. By the way, the handling of the overrides argument is a bit strange, because the passed values will not override anything at the end of the day if the variable exists already. Maybe the setdefault used there is not intentional and it should have been a set instead. |
@bmoelans do i understand correctly, that you have an environment variable if so, you can just read the file without any overriding. the |
Well the reason of the issue is that we use docker containers for development and that certain variables are already set in docker-compose.yml file before launching Django. The reason behind this is that any developer can run the software out of the box. What is the reason behind the fact that you do not allow to override already set settings? What I did to solve it for now:
|
i have no idea; not my code; just came to use this recently myself :) my pull request would make your code sample work and override DATABASE_URL and DJANGO_SITE_TYPE. |
so is there any result? |
The PR adds a new argument -- I can only see one downside -- if "overrides" had a value named 'overwrite', then it would enable overwrite behavior. It is unfortunate the the module uses **overrides as it does, since this puts a limit on adding any new keyword arguments. I would personally like to see read_env deprecated as written, and replaced with a more flexible version, i.e.
|
Any chance of merging this PR? |
+1 for merging PR #191. The similar https://github.com/theskumar/python-dotenv#getting-started |
any news on when this PR could be merged ? |
I would also like this PR to be merged. I set fake |
Also would love for this to be merged. |
Simple to load env file to override environments from settings:
|
This is resolved in |
I have
Problem is that in my ENV_FILE, I want to set
DATABASE_URL
that already has a value when reading the ENV_FILE.But because
def read_env(env_file=None, **overrides)
usessetdefault(key, str(val))
this value can not be overwritten.Is it possible to extend
def read_env
with an extra boolean argument to decide whether or not to override existing environment variables?The text was updated successfully, but these errors were encountered: