-
-
Notifications
You must be signed in to change notification settings - Fork 315
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
Restore defaults in .env #523
Comments
Not sure I've understood clearly your issue, but I was running into "cached" .env variables myself and seems like there's a an override="False" set by default in read_env. Set it to True and it will override previously cached/saved environment variables. Is that the issue you were encountering? |
Can't see override option of read_env. Do you mean overwrite? Will try explain scenario: I have settings.py with
.env file with
Now it is ok, KEY is equal to 3. If I want to change KEY to e.g. 5, I will change it in .env file
Development django reloads (I've added watchdog on .env file). Now I need to reset KEY to initial value, and I try to change .env file:
It is reloaded/restarted again. Of course, I can kill/start server. Of course, I can set KEY to initial value. So I suppose to add special sign to use default value from settings.py
will lead to 0. |
I see your use case now. |
No, I think you don't catch. I describe very common scenario that any developer encounter with while development stage with any values in .env file. Well, if it hard to understand, I will do a patch. |
@dacotagh Could you provide a real-world example why and where is this needed? Case in point from Cloud Run revisions docs:
If the setting you're changing it's meant to be configured more often, you might be interested in some other configuration method (e.g. database-backed), such as Constance. |
No, you're talking about dynamic settings, but I'm talking about static settings and it's changes for testing purpose. We have ordinal configuration: django application, development config (runserver + sqlite), production config (uwsgi + postgres). Now I need to change some of these settings for testing purpose (it can be development configuration or production as well). For example, we have SESSION_SECURITY_EXPIRE_AFTER variable.
for development configuration and
for production configuration I want to change it to 30 seconds to test, so I add to .env file line
django reloads application just like it does for any changes in python code. After successful testing I want to change it back. So we have some strange situation - for any of changes or settings in python code I can change it forward and back easily, but for values in .env I can't do the same, because it persists in environ. Before using Environ we used 'import local_settings.py' pattern and we haven't such problem. |
When we add some values into .env file, there is no way to remove those values until kill/start server (reload/restart doesn't help).
Is it any way to restore default values?
If no, maybe it could be implemented as special syntax, for example with minus before name?
settings.py:
.env:
this doesn't work, KEY is still 3:
Suggestion for .env (should make KEY 0):
The text was updated successfully, but these errors were encountered: