Skip to content

Commit 2fbcb3a

Browse files
committed
postgresql
1 parent 407c3fe commit 2fbcb3a

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

backend/bookinn/settings.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
BASE_DIR = Path(__file__).resolve().parent.parent
88

9+
910
load_dotenv()
1011
SECRET_KEY = os.getenv("SECRET_KEY", default="supersecretkey")
12+
print(SECRET_KEY)
1113

1214
DEBUG = True
1315

@@ -58,12 +60,25 @@
5860

5961
WSGI_APPLICATION = "bookinn.wsgi.application"
6062

61-
DATABASES = {
62-
"default": {
63-
"ENGINE": "django.db.backends.sqlite3",
64-
"NAME": BASE_DIR / "db.sqlite3",
63+
if os.getenv("DATABASE_TYPE") == "postgresql":
64+
DATABASES = {
65+
"default": {
66+
"ENGINE": os.getenv("ENGINE", default="django.db.backends.postgresql"),
67+
"NAME": os.getenv("NAME", default="postgres"),
68+
"USER": os.getenv("USER", default="postgres"),
69+
"PASSWORD": os.getenv("PASSWORD", default="postgres"),
70+
"HOST": os.getenv("HOST", default="localhost"),
71+
"PORT": os.getenv("PORT", default="5432"),
72+
}
6573
}
66-
}
74+
else:
75+
DATABASES = {
76+
"default": {
77+
"ENGINE": "django.db.backends.sqlite3",
78+
"NAME": BASE_DIR / "db.sqlite3",
79+
}
80+
}
81+
6782

6883
AUTH_PASSWORD_VALIDATORS = [
6984
{

0 commit comments

Comments
 (0)