question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What is the reasoning behind DJANGO_READ_DOT_ENV_FILE?

See original GitHub issue

Since this commit, the .env isn’t loaded without manually setting DJANGO_READ_DOT_ENV_FILE.

The comment states:

.env file, should load only in development environment

I don’t really agree with this since we use .env files extensively on production servers. Not a big problem as we can easily add DJANGO_READ_DOT_ENV_FILE to the supervisor config. But I don’t understand what problem it fixes.

For local development this is a bit cumbersome. There’s no documentation explaining the need to set this variable. I’d expect it here for example.

This env variable also isn’t set in local docker config (dev.yml), disabling the possibility to overwrite settings via a .env file.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

9reactions
jeffcjohnsoncommented, Aug 28, 2017

I was just looking to see how I could use the .env file in dev automatically without needing to define the DJANGO_READ_DOT_ENV_FILE environment variable. This little hack in config/settings/local.py seems to do the trick nicely. I figured it might give the next person a head start. If there is a better way please let us know.

config/settings/local.py

import socket
import os
os.environ["DJANGO_READ_DOT_ENV_FILE"] = "true"
from .base import *  # noqa
9reactions
pydannycommented, Jul 29, 2017

Are you given though to this on replacing django-environ with another package or to develop an inhouse implementation?

Replacing this package will be a lot of work. Except for some edge cases, it works okay, so why spend the effort? Also, I would rather piggy back of a package then invent something new that has to be maintained. Unless there’s a pressing need, and funds to support the reviews by core maintainers are made available, we’re not switching.

If the alternative is to incorporate another package, which one would be a good candidate?

Why don’t you do the research yourself instead of asking others to volunteer their free time? Compare a dozen options for suitability, summarize the ones you think are good, and suggest the best three in a separate issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the reasoning behind ...
I was just looking to see how I could use the .env file in dev automatically without needing to define the DJANGO_READ_DOT_ENV_FILE environment ......
Read more >
31 - Environment Variables & dotenv - Python & Django 3.2 ...
31 - Environment Variables & dotenv - Python & Django 3.2 Tutorial SeriesTry Django 3.2 is a series to teach you the fundamentals...
Read more >
environment variables - What is the use of python-dotenv?
.env is a simple text file with each environment variable listed one per line, in the format of KEY="Value". The lines starting with ......
Read more >
Django - How to keep secrets safe with python-dotenv
The secret key that comes with every django project - This needs to be kept private because it's the crucial part of security...
Read more >
How To Handle Environment Variables In Python - PyBites
In this article I will share 3 libraries I often use to isolate my environment variables from production code.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found