From 05de2584fabe4c023a59037a21acaf15f0b01771 Mon Sep 17 00:00:00 2001 From: Nick Cannariato <434063+nickcannariato@users.noreply.github.com> Date: Thu, 19 Mar 2020 03:08:46 -0500 Subject: [PATCH] Also catch NameError exceptions in read_env 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. --- environ/environ.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environ/environ.py b/environ/environ.py index 37c0fb8f..8b8c75c8 100644 --- a/environ/environ.py +++ b/environ/environ.py @@ -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)