From 99dca21777ee8de8fbb89acbc044db93fd67086e Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Tue, 23 Feb 2021 14:59:58 +0100 Subject: [PATCH] Adapt settings.py for deployment --- wish/settings.py | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/wish/settings.py b/wish/settings.py index b60f325..d46c9bc 100644 --- a/wish/settings.py +++ b/wish/settings.py @@ -11,6 +11,17 @@ https://docs.djangoproject.com/en/3.1/ref/settings/ """ from pathlib import Path +from os.path import isfile + +SECRETS_FILE = '~/wish.secrets' +if isfile(SECRETS_FILE): + with open(SECRETS_FILE, "r") as f: + DEBUG = False + SECRET_KEY = f.readline().strip() +else: + DEBUG = True + # Bad, old, already has been in Git... + SECRET_KEY = 'h-mqswfvdslj#c@p264l*@qpsmsj6$$c052dsrh7a^(uza4q2a' # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent @@ -19,12 +30,6 @@ BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'h-mqswfvdslj#c@p264l*@qpsmsj6$$c052dsrh7a^(uza4q2a' - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True - ALLOWED_HOSTS = [] @@ -82,12 +87,15 @@ WSGI_APPLICATION = 'wish.wsgi.application' # Database # https://docs.djangoproject.com/en/3.1/ref/settings/#databases -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': BASE_DIR / 'db.sqlite3', +if DEBUG: + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } } -} +else: + ... # Password validation