128 lines
3.6 KiB
Python
128 lines
3.6 KiB
Python
import environ
|
|
from pathlib import Path
|
|
|
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
|
env = environ.Env(
|
|
DEBUG=(bool, False),
|
|
DJANGO_LOG_LEVEL=(str, "INFO"),
|
|
ALLOWED_HOSTS=(list, []),
|
|
CSRF_TRUSTED_ORIGINS=(list, []),
|
|
ULTIMATE_API_KEY=(str, ""),
|
|
SECURE_SSL_REDIRECT=(bool, False),
|
|
SECURE_HSTS_SECONDS=(int, 0),
|
|
SECURE_HSTS_INCLUDE_SUBDOMAINS=(bool, False),
|
|
SECURE_HSTS_PRELOAD=(bool, False),
|
|
SESSION_COOKIE_SECURE=(bool, True),
|
|
CSRF_COOKIE_SECURE=(bool, True),
|
|
STATIC_URL=(str, "/static/"),
|
|
STATIC_ROOT=(str, BASE_DIR / "static"),
|
|
)
|
|
|
|
for stem in [".env.local", ".env"]:
|
|
env_file = BASE_DIR / stem
|
|
if env_file.exists():
|
|
environ.Env.read_env(env_file)
|
|
|
|
SECRET_KEY = env("SECRET_KEY")
|
|
DEBUG = env("DEBUG")
|
|
DJANGO_LOG_LEVEL = env("DJANGO_LOG_LEVEL")
|
|
ALLOWED_HOSTS = env("ALLOWED_HOSTS")
|
|
CSRF_TRUSTED_ORIGINS = env("CSRF_TRUSTED_ORIGINS")
|
|
ULTIMATE_API_KEY = env("ULTIMATE_API_KEY")
|
|
|
|
SECURE_SSL_REDIRECT = env("SECURE_SSL_REDIRECT")
|
|
SECURE_HSTS_SECONDS = env("SECURE_HSTS_SECONDS")
|
|
SECURE_HSTS_INCLUDE_SUBDOMAINS = env("SECURE_HSTS_INCLUDE_SUBDOMAINS")
|
|
SECURE_HSTS_PRELOAD = env("SECURE_HSTS_PRELOAD")
|
|
SESSION_COOKIE_SECURE = env("SESSION_COOKIE_SECURE")
|
|
CSRF_COOKIE_SECURE = env("CSRF_COOKIE_SECURE")
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = [
|
|
"rest_framework",
|
|
"django.contrib.admin",
|
|
"django.contrib.auth",
|
|
"django.contrib.contenttypes",
|
|
"django.contrib.sessions",
|
|
"django.contrib.messages",
|
|
"django.contrib.staticfiles",
|
|
"frog_api",
|
|
"nested_admin",
|
|
]
|
|
|
|
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 = "frogress.urls"
|
|
|
|
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",
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
WSGI_APPLICATION = "frogress.wsgi.application"
|
|
|
|
|
|
# Database
|
|
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
|
|
|
|
DATABASES = {"default": env.db()}
|
|
|
|
|
|
# Password validation
|
|
# https://docs.djangoproject.com/en/4.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/4.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/4.0/howto/static-files/
|
|
STATIC_URL = env("STATIC_URL")
|
|
STATIC_ROOT = env("STATIC_ROOT")
|
|
|
|
# Default primary key field type
|
|
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
|
|
|
|
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|