diff --git a/lab-1/lab1/settings.py b/lab-1/lab1/settings.py index a6e5ff1..d338113 100644 --- a/lab-1/lab1/settings.py +++ b/lab-1/lab1/settings.py @@ -10,6 +10,7 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/6.0/ref/settings/ """ +import os from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. @@ -20,12 +21,13 @@ BASE_DIR = Path(__file__).resolve().parent.parent # See https://docs.djangoproject.com/en/6.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure--xqwhdo2$)n*y3yk=d*vmwx6nuwt8h=m5@_og_uzj+11^hu7))' +# Ключ по умолчанию — только для локального запуска лабораторной; на сервере задаётся DJANGO_SECRET_KEY +SECRET_KEY = os.environ.get("DJANGO_SECRET_KEY", "django-insecure-lab-dev-key-change-me") # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = os.environ.get("DJANGO_DEBUG", "True") == "True" -ALLOWED_HOSTS = ['*'] +ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS", "*").split(",") # Application definition @@ -75,8 +77,6 @@ WSGI_APPLICATION = 'lab1.wsgi.application' # Database # https://docs.djangoproject.com/en/6.0/ref/settings/#databases -import os - DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', diff --git a/lab-2/caddy/backend/lab1/settings.py b/lab-2/caddy/backend/lab1/settings.py index 397c0f2..f9a1f80 100644 --- a/lab-2/caddy/backend/lab1/settings.py +++ b/lab-2/caddy/backend/lab1/settings.py @@ -10,6 +10,7 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/6.0/ref/settings/ """ +import os from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. @@ -20,12 +21,13 @@ BASE_DIR = Path(__file__).resolve().parent.parent # See https://docs.djangoproject.com/en/6.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure--xqwhdo2$)n*y3yk=d*vmwx6nuwt8h=m5@_og_uzj+11^hu7))' +# Ключ по умолчанию — только для локального запуска лабораторной; на сервере задаётся DJANGO_SECRET_KEY +SECRET_KEY = os.environ.get("DJANGO_SECRET_KEY", "django-insecure-lab-dev-key-change-me") # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = os.environ.get("DJANGO_DEBUG", "True") == "True" -ALLOWED_HOSTS = ['*'] +ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS", "*").split(",") CSRF_TRUSTED_ORIGINS = ['http://localhost', 'https://localhost'] @@ -76,8 +78,6 @@ WSGI_APPLICATION = 'lab1.wsgi.application' # Database # https://docs.djangoproject.com/en/6.0/ref/settings/#databases -import os - DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', diff --git a/lab-2/local/backend/lab1/settings.py b/lab-2/local/backend/lab1/settings.py index 91da8aa..1cd3a06 100644 --- a/lab-2/local/backend/lab1/settings.py +++ b/lab-2/local/backend/lab1/settings.py @@ -10,6 +10,7 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/6.0/ref/settings/ """ +import os from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. @@ -20,12 +21,13 @@ BASE_DIR = Path(__file__).resolve().parent.parent # See https://docs.djangoproject.com/en/6.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure--xqwhdo2$)n*y3yk=d*vmwx6nuwt8h=m5@_og_uzj+11^hu7))' +# Ключ по умолчанию — только для локального запуска лабораторной; на сервере задаётся DJANGO_SECRET_KEY +SECRET_KEY = os.environ.get("DJANGO_SECRET_KEY", "django-insecure-lab-dev-key-change-me") # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = os.environ.get("DJANGO_DEBUG", "True") == "True" -ALLOWED_HOSTS = ['*'] +ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS", "*").split(",") CSRF_TRUSTED_ORIGINS = ['http://localhost'] @@ -76,8 +78,6 @@ WSGI_APPLICATION = 'lab1.wsgi.application' # Database # https://docs.djangoproject.com/en/6.0/ref/settings/#databases -import os - DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql',