Skip to content

Commit

Permalink
fix: use env variable to run django locally
Browse files Browse the repository at this point in the history
  • Loading branch information
cquinn540 committed Nov 7, 2024
1 parent 371a66d commit a6d041f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions .env.dev.local
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DATABASE_HOST="localhost"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ frontend/.github/
.env
.env.*
!.env.dev
!.env.dev.local
dist

# Node dependencies
Expand Down
9 changes: 8 additions & 1 deletion backend/backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@
from rest_framework.settings import api_settings

django_stubs_ext.monkeypatch(extra_classes=(viewsets.ModelViewSet,))
dotenv.load_dotenv()

PROJECT_ROOT = Path(__file__).resolve().parent.parent.parent

if os.getenv("DJANGO_ENV") == "LOCAL_DEV":
dotenv.load_dotenv(override=True, dotenv_path=PROJECT_ROOT / ".env.dev")
dotenv.load_dotenv(override=True, dotenv_path=PROJECT_ROOT / ".env.dev.local")
else:
dotenv.load_dotenv()


DATABASE_HOST = os.getenv("DATABASE_HOST")
Expand Down

0 comments on commit a6d041f

Please sign in to comment.