-
Notifications
You must be signed in to change notification settings - Fork 222
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
fix bug 1123908 - use env vars for django config #2684
fix bug 1123908 - use env vars for django config #2684
Conversation
@@ -376,12 +346,260 @@ def COMPRESS_JINJA2_GET_ENVIRONMENT(): | |||
# all the migrations. | |||
SOUTH_TESTS_MIGRATE = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not all of these?
The point of having SOUTH_TESTS_MIGRATE
(for example) here in settings is so you can override them if you need to.
Well, it's kinda nice to have them written all down in one place too I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after irc conversation, I'm taking this point back.
One thing that's missing the At the moment I honestly don't know the difference between Either way, this PR is great for production whereby you will never rely on a disk file for settings but if we land this we'll leave developers stranded. Also, I'm uncertain still why you left out some settings. Human oversight or deliberate? |
Hm, so the problem is that
I'm not sure how to override some (they are marked with Having to edit the @peterbe do you think we should allow every single thing to be overridden? Not sure how to even approach something like |
COMPRESS_OFFLINE = config('COMPRESS_OFFLINE', True, cast=bool) | ||
|
||
# Make this unique, and don't share it with anybody. It cannot be blank. | ||
SECRET_KEY = config('SECRET_KEY', 'you must change this') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you use SECRET_KEY = config('SECRET_KEY')
I think it'll raise a UndefinedValueError if it's not provided with a value.
And I don't understand why And we will need to start django in other places than just uwsgi. E.g. We basically want production to be 100% environment variables and local developers to be 100% |
We want to use environment variables in prod and no config files, it'll be running like this:
So whenever the key |
@peterbe you mentioned in IRC possibly having a I wonder if it would be possible instead to inject configuration into the shell.. for instance I could see doing We really want to avoid pushing any kind of state to the nodes other than the apps themselves. |
To answer my own question - I don't think you can start an interactive shell with
We could easily have an alias or script that acts as an entry point for |
8aa5ae5
to
ce26fd6
Compare
@peterbe actually I realized that we need to not break PHX (we need to keep using This gives us some time to move the docs and dev config over, without blocking us using environment variables for production in AWS. What do you think? |
raise exc | ||
except ImportError: | ||
print ('WARNING - no local.py' | ||
' (deprecated, use environment variables instead)') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this to just after from .local import *
? I.e. it's deprecated to use local.py
.
Also, instead of print can you change to:
import warnings
warnings.warn(
"Use environment variables instead or a .env file",
DeprecationWarning
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@peterbe sorry I don't understand:
Can you move this to just after
from .local import *
Isn't it already just after it?
Also - I changed from print
to warnings.warn
but I don't see it printed when I do e.g. ./manage.py runserver
, is that because logging is disabled by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean; if it succeeds to import local.py
you're potentially stuck in the old way of doing things. And you need to re-organize yourself away from local.py
to a new .env
file instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean; if it succeeds to import local.py you're potentially stuck in the old way of doing things. And you need to re-organize yourself away from local.py to a new .env file instead.
Oh! I see, so warn if there is a local.py, not if there is not. Sure, makes sense.
@peterbe ah the deprecation warning problem is https://code.djangoproject.com/ticket/18985 and they include an example in their docs (which is the default in |
2ae7db3
to
5d7a052
Compare
@peterbe ok this is ready for review again! |
), | ||
'LOCATION': config( | ||
'CACHE_LOCATiON', | ||
'crashstats', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this supposed to default to 127.0.0.1:11211
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this supposed to default to 127.0.0.1:11211?
Hm well the default is LocMemCache
right?
r+ The only nit is that I don't see any developer-hand-holding with regards to setting up that |
@peterbe what hand-holding did you have in mind? Something in the developer section of the docs, or were you thinking of something else? |
Yes, documentation is what I meant. Soft stuff. You're so ahead of me on terms of the beginner documentation so it's rubberstamp=r+ on it if you do anything. |
45a4d8a
to
7e9861c
Compare
7e9861c
to
e9bf32e
Compare
…r-django-app fix bug 1123908 - use env vars for django config
@peterbe @AdrianGaudebert I just mechanically merged
local.py
intobase.py
and converted all settings to usepython-decouple
(which supports reading configuration from the environment.)There are a few
TODO
s in here, and we should discuss whether we want to further merge user-configurable settings with thebase.py
defaults, but I wanted to do something that was easier to understand in diff form to start the discussion.TODO
slocal.py
overrides to work, while we're still in PHX