timetracker/timetracker/settings.py

154 lines
4.0 KiB
Python
Raw Normal View History

2022-12-31 13:18:27 +00:00
"""
Django settings for timetracker project.
2022-12-31 13:18:27 +00:00
Generated by 'django-admin startproject' using Django 4.1.4.
For more information on this file, see
https://docs.djangoproject.com/en/4.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.1/ref/settings/
"""
2023-01-03 19:41:26 +00:00
import os
2023-01-15 22:39:52 +00:00
from pathlib import Path
2022-12-31 13:18:27 +00:00
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "django-insecure-x0_t$gei=_o_p(%%!-db$jezka@y+d67$a8tvw13nl^8$l*t@="
# SECURITY WARNING: don't run with debug turned on in production!
2023-01-05 20:56:57 +00:00
DEBUG = False if os.environ.get("PROD") else True
2022-12-31 13:18:27 +00:00
2023-01-02 17:29:27 +00:00
ALLOWED_HOSTS = ["*"]
2022-12-31 13:18:27 +00:00
# Application definition
INSTALLED_APPS = [
"games.apps.GamesConfig",
2022-12-31 13:18:27 +00:00
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
]
2023-09-16 16:17:36 +00:00
# if DEBUG:
INSTALLED_APPS.append("django_extensions")
INSTALLED_APPS.append("django.contrib.admin")
2023-01-05 20:56:57 +00:00
2022-12-31 13:18:27 +00:00
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"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 = "timetracker.urls"
2022-12-31 13:18:27 +00:00
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"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",
"games.views.model_counts",
2022-12-31 13:18:27 +00:00
],
},
},
]
WSGI_APPLICATION = "timetracker.wsgi.application"
2022-12-31 13:18:27 +00:00
# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}
# Password validation
# https://docs.djangoproject.com/en/4.1/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/4.1/topics/i18n/
LANGUAGE_CODE = "en-us"
2023-01-05 20:56:57 +00:00
TIME_ZONE = "Europe/Prague" if DEBUG else os.environ.get("TZ", "UTC")
2022-12-31 13:18:27 +00:00
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.1/howto/static-files/
STATIC_URL = "static/"
2023-01-07 20:09:47 +00:00
STATIC_ROOT = BASE_DIR / "static"
2022-12-31 13:18:27 +00:00
# Default primary key field type
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
2023-01-03 18:01:17 +00:00
# https://docs.djangoproject.com/en/4.1/topics/logging/
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
2023-01-05 21:14:51 +00:00
"handlers": {
"console": {"class": "logging.StreamHandler"},
},
"loggers": {
"django": {
"handlers": ["console"],
"level": "INFO",
},
},
2023-01-03 18:01:17 +00:00
}
2023-01-03 19:11:59 +00:00
_csrf_trusted_origins = os.environ.get("CSRF_TRUSTED_ORIGINS")
if _csrf_trusted_origins:
CSRF_TRUSTED_ORIGINS = _csrf_trusted_origins.split(",")
else:
CSRF_TRUSTED_ORIGINS = []
USE_L10N = False