Skip to content

Commit 5ea9b7a

Browse files
Fix incorrect load_dotenv() usage in Django deployment guide (mdn#43114)
* Fix incorrect load_dotenv() usage in Django deployment guide * Apply suggestion from @hamishwillee --------- Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
1 parent 15921c8 commit 5ea9b7a

File tree

1 file changed

+4
-2
lines changed
  • files/en-us/learn_web_development/extensions/server-side/django/deployment

1 file changed

+4
-2
lines changed

files/en-us/learn_web_development/extensions/server-side/django/deployment/index.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,10 @@ Then open **/locallibrary/settings.py** and insert the following code after `BAS
127127
# Support env variables from .env file if defined
128128
import os
129129
from dotenv import load_dotenv
130-
env_path = load_dotenv(os.path.join(BASE_DIR, '.env'))
131-
load_dotenv(env_path)
130+
131+
env_path = os.path.join(BASE_DIR, ".env")
132+
if os.path.exists(env_path):
133+
load_dotenv(env_path)
132134
```
133135

134136
This loads the `.env` file from the root of the web application.

0 commit comments

Comments
 (0)