Skip to content

Commit

Permalink
Also catch NameError exceptions in read_env
Browse files Browse the repository at this point in the history
The django.conf.settings module could be successfully imported but the
BASE_DIR constant could not be defined, which would raise a NameError.

This small edit ensures that we're catching both potential failures.
  • Loading branch information
birdcar committed Sep 5, 2021
1 parent 21aabba commit 05de258
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion environ/environ.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ def read_env(cls, env_file=None, **overrides):
try:
from django.conf import settings
env_file = os.path.join(settings.BASE_DIR, '.env')
except ImportError:
except (ImportError, NameError):
logger.info(
"%s doesn't exist - if you're not configuring your "
"environment separately, create one." % env_file)
Expand Down

0 comments on commit 05de258

Please sign in to comment.