149 lines
4.0 KiB
Python
149 lines
4.0 KiB
Python
"""
|
|
Django settings for app project.
|
|
|
|
Generated by 'django-admin startproject' using Django 6.0.6.
|
|
|
|
For more information on this file, see
|
|
https://docs.djangoproject.com/en/6.0/topics/settings/
|
|
|
|
For the full list of settings and their values, see
|
|
https://docs.djangoproject.com/en/6.0/ref/settings/
|
|
"""
|
|
|
|
from pathlib import Path
|
|
|
|
from app.config import settings as env
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
|
SECRET_KEY = env.django_secret_key
|
|
DEBUG = env.debug
|
|
ALLOWED_HOSTS = env.allowed_hosts
|
|
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = [
|
|
"django.contrib.admin",
|
|
"django.contrib.auth",
|
|
"django.contrib.contenttypes",
|
|
"django.contrib.sessions",
|
|
"django.contrib.messages",
|
|
"django.contrib.staticfiles",
|
|
"scores",
|
|
*env.installed_apps,
|
|
]
|
|
|
|
API_SECRET = env.api_secret
|
|
USE_X_FORWARDED_HOST = True
|
|
FORCE_SCRIPT_NAME = env.force_script_name
|
|
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
|
|
|
|
MIDDLEWARE = [
|
|
"django.middleware.security.SecurityMiddleware",
|
|
"whitenoise.middleware.WhiteNoiseMiddleware",
|
|
"django.contrib.sessions.middleware.SessionMiddleware",
|
|
"django.middleware.common.CommonMiddleware",
|
|
"django.middleware.csrf.CsrfViewMiddleware",
|
|
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
|
"django.contrib.messages.middleware.MessageMiddleware",
|
|
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
|
]
|
|
|
|
ROOT_URLCONF = "app.urls"
|
|
|
|
TEMPLATES = [
|
|
{
|
|
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
"DIRS": [],
|
|
"APP_DIRS": True,
|
|
"OPTIONS": {
|
|
"context_processors": [
|
|
"django.template.context_processors.request",
|
|
"django.contrib.auth.context_processors.auth",
|
|
"django.contrib.messages.context_processors.messages",
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
WSGI_APPLICATION = "app.wsgi.application"
|
|
|
|
|
|
# Database
|
|
# https://docs.djangoproject.com/en/6.0/ref/settings/#databases
|
|
|
|
DATABASES = {
|
|
"default": {
|
|
"ENGINE": env.db_engine,
|
|
"NAME": env.db_name,
|
|
"USER": env.db_user,
|
|
"PASSWORD": env.db_password,
|
|
"HOST": env.db_host,
|
|
"PORT": env.db_port,
|
|
}
|
|
}
|
|
|
|
|
|
# Password validation
|
|
# https://docs.djangoproject.com/en/6.0/ref/settings/#auth-password-validators
|
|
|
|
AUTH_PASSWORD_VALIDATORS = [
|
|
{
|
|
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
|
|
},
|
|
{
|
|
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
|
|
},
|
|
{
|
|
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
|
|
},
|
|
{
|
|
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
|
|
},
|
|
]
|
|
|
|
|
|
# Internationalization
|
|
# https://docs.djangoproject.com/en/6.0/topics/i18n/
|
|
|
|
LANGUAGE_CODE = "en-us"
|
|
|
|
TIME_ZONE = "UTC"
|
|
|
|
USE_I18N = True
|
|
|
|
USE_TZ = True
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
# https://docs.djangoproject.com/en/6.0/howto/static-files/
|
|
|
|
# STATIC_URL/MEDIA_URL are literal strings; Django never prepends SCRIPT_NAME to
|
|
# them, so the prefix must be added manually for the admin assets to load under
|
|
# the /scores sub-path.
|
|
STATIC_URL = f"{FORCE_SCRIPT_NAME.rstrip('/')}/static/"
|
|
STATIC_ROOT = BASE_DIR / "staticfiles"
|
|
|
|
# WhiteNoise serves static files directly from the app (no separate web server
|
|
# needed), with compression and far-future cache headers. In production the
|
|
# manifest backend hashes filenames for cache-busting (requires collectstatic);
|
|
# locally we skip the manifest and serve straight from the finders so no
|
|
# collectstatic step is needed.
|
|
STORAGES = {
|
|
"default": {
|
|
"BACKEND": "django.core.files.storage.FileSystemStorage",
|
|
},
|
|
"staticfiles": {
|
|
"BACKEND": (
|
|
"whitenoise.storage.CompressedStaticFilesStorage"
|
|
if DEBUG
|
|
else "whitenoise.storage.CompressedManifestStaticFilesStorage"
|
|
),
|
|
},
|
|
}
|
|
|
|
# Serve static files from the app dirs in development (we run under daphne, which
|
|
# does not auto-serve static like runserver does).
|
|
WHITENOISE_USE_FINDERS = DEBUG
|