|
12 | 12 |
|
13 | 13 | import os |
14 | 14 | from pathlib import Path |
| 15 | +from urllib.parse import urlparse, parse_qsl |
| 16 | + |
| 17 | +tmpPostgres = urlparse(os.getenv("DATABASE_URL")) |
15 | 18 |
|
16 | 19 | # Build paths inside the project like this: BASE_DIR / 'subdir'. |
17 | 20 | BASE_DIR = Path(__file__).resolve().parent.parent |
|
81 | 84 |
|
82 | 85 | DATABASES = { |
83 | 86 | "default": { |
84 | | - "ENGINE": "django.db.backends.postgresql", |
85 | | - "NAME": os.environ.get("DB_NAME", "your_db_name"), |
86 | | - "USER": os.environ.get("DB_USER", "your_db_user"), |
87 | | - "PASSWORD": os.environ.get("DB_PASSWORD", "your_db_password"), |
88 | | - "HOST": os.environ.get("DB_HOST", "your_db_host"), |
89 | | - "PORT": os.environ.get("DB_PORT", "5432"), |
| 87 | + 'ENGINE': 'django.db.backends.postgresql', |
| 88 | + 'NAME': tmpPostgres.path.replace('/', ''), |
| 89 | + 'USER': tmpPostgres.username, |
| 90 | + 'PASSWORD': tmpPostgres.password, |
| 91 | + 'HOST': tmpPostgres.hostname, |
| 92 | + 'PORT': 5432, |
| 93 | + 'OPTIONS': dict(parse_qsl(tmpPostgres.query)), |
90 | 94 | }, |
91 | 95 | "sqlite3": { |
92 | 96 | "ENGINE": "django.db.backends.sqlite3", |
|
0 commit comments