-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Trivial - P5
-
None
-
Affects Version/s: None
-
Component/s: django
-
None
Summary
The django-mongodb-project template currently hardcodes the MongoDB connection URI. It should fall back to os.getenv("MONGODB_URI", "mongodb://127.0.0.1:27017") so that:
- Developers can point at any MongoDB instance by setting MONGODB_URI in their environment (e.g. Atlas, a remote dev cluster, Docker)
- The default mongodb://127.0.0.1:27017 is used when no env var is set, preserving current local-dev behavior
Change
In project_name/settings/base.py, replace the hardcoded URI with:
import os DATABASES = { "default": { "ENGINE": "django_mongodb_backend", "HOST": os.getenv("MONGODB_URI", "mongodb://127.0.0.1:27017"), } }
(Adjust field name — HOST or NAME — to match however the current settings parse the URI via django-mongodb-backend.)
Acceptance Criteria
- Setting MONGODB_URI=mongodb+srv://... in the environment connects to that cluster
- Omitting MONGODB_URI defaults to mongodb://127.0.0.1:27017