/
lesbeg
/
django-script-consent
Обзор
Документация
Войти
/
lesbeg
/
django-script-consent
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
2
CI/CD
Аналитика
Безопасность
master
example_project/settings.py
85 строк
3 KB
Anton Trapeznikov
0.2.0 RC
02 авг 2026, 23:16
02 авг 2026, 23:16
69f5b51
Код
Авторство
О чём код?
import os from pathlib import Path BASE_DIR = Path(__file__).resolve().parent SECRET_KEY = os.environ.get("SECRET_KEY", "example-only-not-for-production") DEBUG = os.environ.get("DEBUG", "1") not in ("0", "false", "False", "") _allowed = os.environ.get("ALLOWED_HOSTS", "*").strip() ALLOWED_HOSTS = [h.strip() for h in _allowed.split(",") if h.strip()] or ["*"] _csrf = os.environ.get("CSRF_TRUSTED_ORIGINS", "").strip() CSRF_TRUSTED_ORIGINS = [o.strip() for o in _csrf.split(",") if o.strip()] INSTALLED_APPS = [ "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", "script_consent", # Last: hides User/Group from admin (see ExampleProjectConfig.ready) "example_project.apps.ExampleProjectConfig", ] MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", "django.middleware.locale.LocaleMiddleware", "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", ] ROOT_URLCONF = "example_project.urls" TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", "DIRS": [BASE_DIR / "templates"], "APP_DIRS": True, "OPTIONS": { "context_processors": [ "django.template.context_processors.debug", "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", "script_consent.context_processors.script_consent", ], }, }, ] DATABASES = { "default": { "ENGINE": "django.db.backends.sqlite3", "NAME": os.environ.get("SQLITE_PATH", str(BASE_DIR / "db.sqlite3")), } } CACHES = { "default": { "BACKEND": "django.core.cache.backends.locmem.LocMemCache", } } LANGUAGE_CODE = os.environ.get("LANGUAGE_CODE", "en") LANGUAGES = [ ("en", "English"), ("ru", "Russian"), ] TIME_ZONE = os.environ.get("TIME_ZONE", "UTC") USE_I18N = True USE_TZ = True STATIC_URL = "/static/" STATIC_ROOT = BASE_DIR / "staticfiles" DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" SCRIPT_CONSENT = { "PRIVACY_POLICY_URL": "/privacy/", }