From c3a973b6c7538584d449fcfdd404d05ec2a11fb4 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sat, 2 Mar 2019 16:31:09 +0100 Subject: [PATCH] Support database url --- Pipfile | 1 + Pipfile.lock | 10 +++++++++- friends_map/settings.py | 10 +++------- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Pipfile b/Pipfile index b181c79..7887ae7 100644 --- a/Pipfile +++ b/Pipfile @@ -7,6 +7,7 @@ name = "pypi" django = "*" gitpython = "*" django-crispy-forms = "*" +dj-database-url = "*" [dev-packages] diff --git a/Pipfile.lock b/Pipfile.lock index 41c5815..f291500 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "a641d67a7e9f7c8b91008ec1d74563f65757dd900d38c5901f7fa3a450dc2be4" + "sha256": "39ab492fa50cd7fb74e60bbd0e7cd1c5b688905cd90c256ff776d06f530af4fb" }, "pipfile-spec": 6, "requires": { @@ -16,6 +16,14 @@ ] }, "default": { + "dj-database-url": { + "hashes": [ + "sha256:4aeaeb1f573c74835b0686a2b46b85990571159ffc21aa57ecd4d1e1cb334163", + "sha256:851785365761ebe4994a921b433062309eb882fedd318e1b0fcecc607ed02da9" + ], + "index": "pypi", + "version": "==0.5.0" + }, "django": { "hashes": [ "sha256:275bec66fd2588dd517ada59b8bfb23d4a9abc5a362349139ddda3c7ff6f5ade", diff --git a/friends_map/settings.py b/friends_map/settings.py index 538bebe..695fb9b 100644 --- a/friends_map/settings.py +++ b/friends_map/settings.py @@ -13,6 +13,8 @@ https://docs.djangoproject.com/en/2.1/ref/settings/ import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) +import dj_database_url + BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) @@ -77,13 +79,7 @@ WSGI_APPLICATION = 'friends_map.wsgi.application' # Database # https://docs.djangoproject.com/en/2.1/ref/settings/#databases - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), - } -} +DATABASES = {'default': dj_database_url.config(default=f'sqlite:///{BASE_DIR}/db.sqlite3', conn_max_age=600)} # Password validation