DEV Community

Discussion on: Django Cheat Sheet: Keep Credentials Secure with Environment Variables

Collapse
 
guettli profile image
Thomas Güttler

Don't ask my why the author did not accept my PR: github.com/theskumar/python-dotenv...

Converting types

The library reads and provides strings. If you need for example a boolean, it is up to you to convert the value.

Example:

from distutils.util import strtobool
DEBUG = bool(strtobool(os.getenv('DEBUG', 'True')))
Enter fullscreen mode Exit fullscreen mode
Collapse
 
derrick_k_429f36beeddff99 profile image
derrick k

I agree, it works perfectly

Collapse
 
niceguydave profile image
David Talbot

This is really helpful, thanks. Agreed—it seems strange that your PR was rejected, given that variables with False values get (confusingly) cast to True.