Skip to content

Commit

Permalink
Use dj-database-url
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Normore committed Oct 28, 2020
1 parent ecc8f8e commit 27ba6f7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
12 changes: 2 additions & 10 deletions mysite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from pathlib import Path
import os
import sys
import dj_database_url
from urllib.parse import urlparse

from django.core.management.utils import get_random_secret_key
Expand Down Expand Up @@ -89,17 +90,8 @@
elif len(sys.argv) > 0 and sys.argv[1] != 'collectstatic':
if os.getenv("DATABASE_URL", None) is None:
raise Exception("DATABASE_URL environment variable not defined")
r = urlparse(os.environ.get("DATABASE_URL"))
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": os.path.relpath(r.path, "/"),
"USER": r.username,
"PASSWORD": r.password,
"HOST": r.hostname,
"PORT": r.port,
"OPTIONS": {"sslmode": "require"},
}
"default": dj_database_url.parse(os.environ.get("DATABASE_URL")),
}


Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ psycopg2-binary==2.8.6
pytz==2020.1
sqlparse==0.3.1
whitenoise==5.2.0
dj-database-url==0.5.0

0 comments on commit 27ba6f7

Please sign in to comment.