From f95cc41ca3f5bcfbbf738c5f0f84d72e870e2a0a Mon Sep 17 00:00:00 2001 From: Leonid Kostrykin Date: Mon, 29 Jan 2024 21:14:10 +0100 Subject: [PATCH] Add production settings --- tournaments/manage.py | 2 +- tournaments/tournaments/settings/__init__.py | 0 .../{settings.py => settings/common.py} | 14 +------------- tournaments/tournaments/settings/development.py | 13 +++++++++++++ tournaments/tournaments/settings/production.py | 16 ++++++++++++++++ 5 files changed, 31 insertions(+), 14 deletions(-) create mode 100644 tournaments/tournaments/settings/__init__.py rename tournaments/tournaments/{settings.py => settings/common.py} (87%) create mode 100644 tournaments/tournaments/settings/development.py create mode 100644 tournaments/tournaments/settings/production.py diff --git a/tournaments/manage.py b/tournaments/manage.py index 07e7cb3..ff2fab3 100755 --- a/tournaments/manage.py +++ b/tournaments/manage.py @@ -6,7 +6,7 @@ def main(): """Run administrative tasks.""" - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tournaments.settings') + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tournaments.settings.development') try: from django.core.management import execute_from_command_line except ImportError as exc: diff --git a/tournaments/tournaments/settings/__init__.py b/tournaments/tournaments/settings/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tournaments/tournaments/settings.py b/tournaments/tournaments/settings/common.py similarity index 87% rename from tournaments/tournaments/settings.py rename to tournaments/tournaments/settings/common.py index 6406e1b..9db1a69 100644 --- a/tournaments/tournaments/settings.py +++ b/tournaments/tournaments/settings/common.py @@ -13,19 +13,7 @@ from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. -BASE_DIR = Path(__file__).resolve().parent.parent - - -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ - -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure-ouqc8j0sk$gn+*9zja*ii=rs=$q()cs$e*9$fg1(y28d#m8m$d' - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True - -ALLOWED_HOSTS = [] +BASE_DIR = Path(__file__).resolve().parent.parent.parent # Application definition diff --git a/tournaments/tournaments/settings/development.py b/tournaments/tournaments/settings/development.py new file mode 100644 index 0000000..d76f5dd --- /dev/null +++ b/tournaments/tournaments/settings/development.py @@ -0,0 +1,13 @@ +from tournaments.settings.common import * + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-ouqc8j0sk$gn+*9zja*ii=rs=$q()cs$e*9$fg1(y28d#m8m$d' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = ['*'] diff --git a/tournaments/tournaments/settings/production.py b/tournaments/tournaments/settings/production.py new file mode 100644 index 0000000..edad21e --- /dev/null +++ b/tournaments/tournaments/settings/production.py @@ -0,0 +1,16 @@ +import os + +from tournaments.settings.common import * + + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = os.environ['SECRET_KEY'] + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = False + +ALLOWED_HOSTS = [ + os.environ['HOSTNAME'], +] + +STATIC_ROOT = BASE_DIR / '../deployed'