-
Notifications
You must be signed in to change notification settings - Fork 23.1k
Open
Labels
Content:LearnLearning area docsLearning area docsneeds triageTriage needed by staff and/or partners. Automatically applied when an issue is opened.Triage needed by staff and/or partners. Automatically applied when an issue is opened.
Description
MDN URL
What specific section or headline is this issue about?
Getting your website ready to publish
What information was incorrect, unhelpful, or incomplete?
import os
from dotenv import load_dotenv
env_path = load_dotenv(os.path.join(BASE_DIR, '.env'))
load_dotenv(env_path)load_dotenv() returns a boolean, not a path. Calling load_dotenv(env_path) therefore passes a boolean instead of a file path and does nothing useful.
What did you expect to see?
Correct approach:
from pathlib import Path
from dotenv import load_dotenv
BASE_DIR = Path(__file__).resolve().parent.parent
ENV_FILE = BASE_DIR / ".env"
# Load .env only if it exists; otherwise rely on system environment variables
if ENV_FILE.exists():
load_dotenv(ENV_FILE)Do you have any supporting links, references, or citations?
Generate an error like:
<frozen genericpath>:39: RuntimeWarning: bool is used as a file descriptor
/path/to/venv/lib/python3.14/site-packages/dotenv/main.py:431: RuntimeWarning: bool is used as a file descriptor
st = os.stat(path)
Do you have anything more you want to share?
No response
MDN metadata
Page report details
- Folder:
en-us/learn_web_development/extensions/server-side/django/deployment - MDN URL: https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Server-side/Django/Deployment
- GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/learn_web_development/extensions/server-side/django/deployment/index.md
- Last commit: 4231617
- Document last modified: 2025-12-29T16:36:42.000Z
Metadata
Metadata
Assignees
Labels
Content:LearnLearning area docsLearning area docsneeds triageTriage needed by staff and/or partners. Automatically applied when an issue is opened.Triage needed by staff and/or partners. Automatically applied when an issue is opened.