generated from bisco/codex-bootstrap
122 lines
3.4 KiB
Python
122 lines
3.4 KiB
Python
import os
|
|
from pathlib import Path
|
|
|
|
import dj_database_url
|
|
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
|
|
|
def env_bool(name: str, default: bool = False) -> bool:
|
|
return os.getenv(name, str(default)).lower() in {"1", "true", "yes", "on"}
|
|
|
|
|
|
DEBUG = env_bool("DJANGO_DEBUG", False)
|
|
SECRET_KEY = os.getenv("DJANGO_SECRET_KEY", "")
|
|
if not SECRET_KEY:
|
|
if DEBUG:
|
|
SECRET_KEY = "development-only-secret-key"
|
|
else:
|
|
raise RuntimeError("DJANGO_SECRET_KEY must be set when DJANGO_DEBUG is false")
|
|
|
|
ALLOWED_HOSTS = [
|
|
host.strip()
|
|
for host in os.getenv("DJANGO_ALLOWED_HOSTS", "localhost,127.0.0.1").split(",")
|
|
if host.strip()
|
|
]
|
|
|
|
INSTALLED_APPS = [
|
|
"home",
|
|
"wagtail.api.v2",
|
|
"wagtail.contrib.forms",
|
|
"wagtail.contrib.redirects",
|
|
"wagtail.contrib.settings",
|
|
"wagtail.embeds",
|
|
"wagtail.sites",
|
|
"wagtail.users",
|
|
"wagtail.snippets",
|
|
"wagtail.documents",
|
|
"wagtail.images",
|
|
"wagtail.search",
|
|
"wagtail.admin",
|
|
"wagtail",
|
|
"modelcluster",
|
|
"taggit",
|
|
"django.contrib.auth",
|
|
"django.contrib.contenttypes",
|
|
"django.contrib.sessions",
|
|
"django.contrib.messages",
|
|
"django.contrib.staticfiles",
|
|
]
|
|
|
|
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",
|
|
"wagtail.contrib.redirects.middleware.RedirectMiddleware",
|
|
]
|
|
|
|
ROOT_URLCONF = "config.urls"
|
|
|
|
TEMPLATES = [
|
|
{
|
|
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
"DIRS": [BASE_DIR / "templates"],
|
|
"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 = "config.wsgi.application"
|
|
|
|
DATABASES = {
|
|
"default": dj_database_url.parse(
|
|
os.getenv("DATABASE_URL", f"sqlite:///{BASE_DIR / 'db.sqlite3'}"),
|
|
conn_max_age=60,
|
|
conn_health_checks=True,
|
|
)
|
|
}
|
|
|
|
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"},
|
|
]
|
|
|
|
LANGUAGE_CODE = "it-it"
|
|
TIME_ZONE = "Europe/Rome"
|
|
USE_I18N = True
|
|
USE_TZ = True
|
|
|
|
STATIC_URL = "/static/"
|
|
STATIC_ROOT = BASE_DIR / "static"
|
|
STORAGES = {
|
|
"default": {"BACKEND": "django.core.files.storage.FileSystemStorage"},
|
|
"staticfiles": {
|
|
"BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage"
|
|
},
|
|
}
|
|
MEDIA_URL = "/media/"
|
|
MEDIA_ROOT = BASE_DIR / "media"
|
|
|
|
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
|
|
|
WAGTAIL_SITE_NAME = "Azione!Lab"
|
|
WAGTAILADMIN_BASE_URL = os.getenv("WAGTAILADMIN_BASE_URL", "http://localhost:8000")
|
|
WAGTAIL_I18N_ENABLED = False
|
|
|
|
DATA_UPLOAD_MAX_MEMORY_SIZE = 10 * 1024 * 1024
|
|
FILE_UPLOAD_MAX_MEMORY_SIZE = 10 * 1024 * 1024
|