Skip to content

Commit

Permalink
Add check if .env file exists before loading it
Browse files Browse the repository at this point in the history
  • Loading branch information
mrchrisadams committed May 15, 2024
1 parent ce13597 commit d9f67c8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion greenweb/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@
),
)

environ.Env.read_env(".env") # Read .env
# in some cases we don't have a .env file to work from - the environment
# variables are provided via docker for example. So, we only try to load the
# .env file if it exists.
dotenv_file = pathlib.Path(ROOT) / ".env"
if dotenv_file.exists():
environ.Env.read_env(".env")


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/
Expand Down

0 comments on commit d9f67c8

Please sign in to comment.