Adapt settings.py for deployment

newer-dal
LEdoian 4 years ago
parent d8a8c80bb0
commit 99dca21777

@ -11,6 +11,17 @@ https://docs.djangoproject.com/en/3.1/ref/settings/
""" """
from pathlib import Path 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'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent 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 # Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ # 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 = [] ALLOWED_HOSTS = []
@ -82,12 +87,15 @@ WSGI_APPLICATION = 'wish.wsgi.application'
# Database # Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases # https://docs.djangoproject.com/en/3.1/ref/settings/#databases
if DEBUG:
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.sqlite3', 'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3',
} }
} }
else:
...
# Password validation # Password validation

Loading…
Cancel
Save