On 12/04/16 04:26, Aymeric Augustin wrote:
On 11 Apr 2016, at 19:39, Curtis Maloney <cur...@tinbrain.net> wrote:
1. All env vars can have a fallback value (the method in my case)
2. You can mark an env var as not having a fallback value, and it will raise an
error at start up if not set.
There’s an additional complexity here.
Usually, it’s best for settings read from environment variables:
a. To use a default value in dev, even if that means a small degradation in
functionality. This allows developers to start working on the project without
adding dozens of exports to their $VIRTUAL_ENV/bin/postactivate, and to add
just the values they need when they work on specific parts like integrations
with third-party systems.
b. To crash if no value is provided in prod, in order to catch configuration
One might think of switching the behavior depending on settings.DEBUG, but
that won't work because the switch is required to load settings properly.
This is all true.... it's generally not an issue when using
django-classy-settings as it was engineered to make it easy to switch
between settings environments such as dev/staging/testing/production.
I’ve seen lots of wrapper that don’t add enough value to be worth it. These
days I just write:
FOO_TOKEN = os.environ.get('FOO_TOKEN', '')
FOO_TOKEN = os.environ['FOO_TOKEN']
It isn’t as dry as it could be, but at least it’s simple.
This is one thing d-c-s helps you avoid... by letting you declare it all
in one file, inherit complex/dependent settings through classes, and
switch between those with an env var [or whatever mechanism you like]
However, this is slightly tangential to the actual discussion
You received this message because you are subscribed to the Google Groups "Django
developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email
To post to this group, send email to firstname.lastname@example.org.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit
For more options, visit https://groups.google.com/d/optout.