File tree 2 files changed +3
-10
lines changed
2 files changed +3
-10
lines changed Original file line number Diff line number Diff line change 12
12
from pathlib import Path
13
13
import os
14
14
import sys
15
+ import dj_database_url
15
16
from urllib .parse import urlparse
16
17
17
18
from django .core .management .utils import get_random_secret_key
89
90
elif len (sys .argv ) > 0 and sys .argv [1 ] != 'collectstatic' :
90
91
if os .getenv ("DATABASE_URL" , None ) is None :
91
92
raise Exception ("DATABASE_URL environment variable not defined" )
92
- r = urlparse (os .environ .get ("DATABASE_URL" ))
93
93
DATABASES = {
94
- "default" : {
95
- "ENGINE" : "django.db.backends.postgresql_psycopg2" ,
96
- "NAME" : os .path .relpath (r .path , "/" ),
97
- "USER" : r .username ,
98
- "PASSWORD" : r .password ,
99
- "HOST" : r .hostname ,
100
- "PORT" : r .port ,
101
- "OPTIONS" : {"sslmode" : "require" },
102
- }
94
+ "default" : dj_database_url .parse (os .environ .get ("DATABASE_URL" )),
103
95
}
104
96
105
97
Original file line number Diff line number Diff line change @@ -5,3 +5,4 @@ psycopg2-binary==2.8.6
5
5
pytz == 2020.1
6
6
sqlparse == 0.3.1
7
7
whitenoise == 5.2.0
8
+ dj-database-url == 0.5.0
You can’t perform that action at this time.
0 commit comments