|
@@ -10,6 +10,9 @@ For the full list of settings and their values, see
|
|
|
https://docs.djangoproject.com/en/4.0/ref/settings/
|
|
|
"""
|
|
|
|
|
|
+import os
|
|
|
+import json
|
|
|
+import socket
|
|
|
from pathlib import Path
|
|
|
|
|
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
@@ -20,13 +23,17 @@ BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
|
|
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
|
-SECRET_KEY = 'django-insecure-xdx9^5o*$-z$qh31^t$*gj8gs2y6ljnbt_c$v+rib5dle1q&&6'
|
|
|
+SECRET_KEY = os.getenv('DJANGO_SECRET_KEY', 'debug_secret_key')
|
|
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
|
-DEBUG = True
|
|
|
+DEBUG = os.getenv('DJANGO_DEBUG', "True") == "True"
|
|
|
|
|
|
-ALLOWED_HOSTS = []
|
|
|
+if DEBUG:
|
|
|
+ hostname, _, ips = socket.gethostbyname_ex(socket.gethostname())
|
|
|
+ INTERNAL_IPS = [ip[: ip.rfind(".")] + ".1" for ip in ips] + ["127.0.0.1", "localhost"]
|
|
|
|
|
|
+ALLOWED_HOSTS = os.getenv('DJANGO_ALLOWED_HOSTS', 'localhost,127.0.0.1').split(',')
|
|
|
+CSRF_TRUSTED_ORIGINS = os.getenv('DJANGO_CSRF_TRUSTED_ORIGINS', 'http://localhost').split(',')
|
|
|
|
|
|
# Application definition
|
|
|
|
|
@@ -50,7 +57,9 @@ MIDDLEWARE = [
|
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
|
]
|
|
|
|
|
|
-ROOT_URLCONF = 'app.urls'
|
|
|
+LOCALE_PATHS = ( os.path.join(BASE_DIR, 'locale'), )
|
|
|
+
|
|
|
+ROOT_URLCONF = 'project.urls'
|
|
|
|
|
|
TEMPLATES = [
|
|
|
{
|
|
@@ -68,7 +77,7 @@ TEMPLATES = [
|
|
|
},
|
|
|
]
|
|
|
|
|
|
-WSGI_APPLICATION = 'app.wsgi.application'
|
|
|
+WSGI_APPLICATION = 'project.wsgi.application'
|
|
|
|
|
|
|
|
|
# Database
|
|
@@ -80,6 +89,19 @@ DATABASES = {
|
|
|
'NAME': BASE_DIR / 'db.sqlite3',
|
|
|
}
|
|
|
}
|
|
|
+DATABASES = {
|
|
|
+ 'default': {
|
|
|
+ 'ENGINE': os.getenv('DATABASE_ENGINE', 'django.db.backends.sqlite3'),
|
|
|
+ 'NAME': os.getenv('DATABASE_NAME', 'db.sqlite3'),
|
|
|
+ 'USER': os.getenv('DATABASE_USERNAME', 'myprojectuser'),
|
|
|
+ 'PASSWORD': os.getenv('DATABASE_PASSWORD', 'password'),
|
|
|
+ 'HOST': os.getenv('DATABASE_HOST', '127.0.0.1'),
|
|
|
+ 'PORT': os.getenv('DATABASE_PORT', 3306),
|
|
|
+ 'OPTIONS': json.loads(
|
|
|
+ os.getenv('DATABASE_OPTIONS', '{}')
|
|
|
+ ),
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
|
|
|
# Password validation
|
|
@@ -110,6 +132,8 @@ TIME_ZONE = 'UTC'
|
|
|
|
|
|
USE_I18N = True
|
|
|
|
|
|
+USE_L10N = True
|
|
|
+
|
|
|
USE_TZ = True
|
|
|
|
|
|
|
|
@@ -118,7 +142,11 @@ USE_TZ = True
|
|
|
|
|
|
STATIC_URL = 'static/'
|
|
|
|
|
|
+STATIC_ROOT = '../static'
|
|
|
+
|
|
|
# Default primary key field type
|
|
|
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
|
|
|
|
|
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
|
|
+
|
|
|
+MEDIA_ROOT = os.path.join(BASE_DIR, '../data')
|