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

django-environ bug with default value #2291

Closed
pablobuenaposada opened this issue Oct 28, 2019 · 4 comments
Closed

django-environ bug with default value #2291

pablobuenaposada opened this issue Oct 28, 2019 · 4 comments
Labels

Comments

@pablobuenaposada
Copy link

pablobuenaposada commented Oct 28, 2019

django-environ==0.4.5 package has an annoying bug where you cannot retrieve env variables if you play with the default option, example:

(venv) wl18dbf200479e:cookiecutter-django pablobuenaposada$ pip freeze | grep django-environ
django-environ==0.4.5
(venv) wl18dbf200479e:cookiecutter-django pablobuenaposada$ python
Python 3.6.5 (default, Sep 12 2018, 15:53:18)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import environ
>>> env = environ.Env()
>>> env('HOME')
'/Users/pablobuenaposada'
>>> env('HOME', default=False)
False

As you can see depending on the default value you could have unexpected results while trying to get you env variables.

You can follow this bug also in the package issue thread here: joke2k/django-environ#192

I would at least pin the django-environ version to 0.4.4 (doesn't support Django 2) where this is not happening but also consider replacing this package by using os.environ.get directly or think in other solutions since I am not confident that the library gets fixed,

@AndreMiras
Copy link

I haven't tried yet, but https://github.com/sloria/environs seems fairly maintained and provides a similar interface

@pablobuenaposada
Copy link
Author

I think this one is also related vchaptsev/cookiecutter-django-vue#45

@Isaac12x
Copy link
Contributor

Isaac12x commented Jan 6, 2020

I have faced that issue too in a different codebase. I know this might be off-topic but check #2195

@browniebroke
Copy link
Member

Going to close this old one as the issue linked is marked as fixed in django-environ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants