2017-08-11 18:32:02 +00:00
|
|
|
import os
|
2020-07-22 03:46:46 +00:00
|
|
|
from distutils.util import strtobool
|
2017-08-11 18:32:02 +00:00
|
|
|
|
2019-04-14 03:09:55 +00:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2017-12-01 03:54:50 +00:00
|
|
|
from dotenv import load_dotenv, find_dotenv
|
|
|
|
|
2017-08-11 18:32:02 +00:00
|
|
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
2022-02-10 00:00:30 +00:00
|
|
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
2017-08-11 18:32:02 +00:00
|
|
|
|
2017-12-01 03:54:50 +00:00
|
|
|
# Environment variables
|
|
|
|
# Check for and load environment variables from a .env file.
|
|
|
|
|
|
|
|
load_dotenv(find_dotenv())
|
2017-08-11 18:32:02 +00:00
|
|
|
|
2017-11-29 20:02:14 +00:00
|
|
|
# Required settings
|
2017-10-23 13:49:09 +00:00
|
|
|
|
2022-02-10 00:00:30 +00:00
|
|
|
ALLOWED_HOSTS = os.environ.get("ALLOWED_HOSTS", "*").split(",")
|
|
|
|
SECRET_KEY = os.environ.get("SECRET_KEY") or None
|
|
|
|
DEBUG = bool(strtobool(os.environ.get("DEBUG") or "False"))
|
2017-10-23 13:49:09 +00:00
|
|
|
|
|
|
|
|
2017-08-19 14:16:51 +00:00
|
|
|
# Applications
|
2024-01-14 04:22:08 +00:00
|
|
|
# https://docs.djangoproject.com/en/5.0/ref/applications/
|
2017-08-11 18:32:02 +00:00
|
|
|
|
|
|
|
INSTALLED_APPS = [
|
2022-02-10 00:00:30 +00:00
|
|
|
"api",
|
2023-02-11 18:31:14 +00:00
|
|
|
"babybuddy.apps.BabyBuddyConfig",
|
|
|
|
"core.apps.CoreConfig",
|
2022-02-10 00:00:30 +00:00
|
|
|
"dashboard",
|
|
|
|
"reports",
|
|
|
|
"axes",
|
|
|
|
"django_filters",
|
|
|
|
"rest_framework",
|
|
|
|
"rest_framework.authtoken",
|
|
|
|
"widget_tweaks",
|
|
|
|
"imagekit",
|
|
|
|
"storages",
|
|
|
|
"import_export",
|
2022-08-30 19:26:45 +00:00
|
|
|
"qr_code",
|
2023-04-15 20:59:44 +00:00
|
|
|
"dbsettings",
|
2022-02-10 00:00:30 +00:00
|
|
|
"django.contrib.admin",
|
|
|
|
"django.contrib.auth",
|
|
|
|
"django.contrib.contenttypes",
|
|
|
|
"django.contrib.sessions",
|
|
|
|
"django.contrib.messages",
|
|
|
|
"django.contrib.staticfiles",
|
|
|
|
"django.contrib.humanize",
|
2017-08-11 18:32:02 +00:00
|
|
|
]
|
|
|
|
|
2017-08-19 14:16:51 +00:00
|
|
|
# Middleware
|
2024-01-14 04:22:08 +00:00
|
|
|
# https://docs.djangoproject.com/en/5.0/ref/middleware/
|
2017-08-19 14:16:51 +00:00
|
|
|
|
2017-08-11 18:32:02 +00:00
|
|
|
MIDDLEWARE = [
|
2022-02-10 00:00:30 +00:00
|
|
|
"django.middleware.security.SecurityMiddleware",
|
|
|
|
"whitenoise.middleware.WhiteNoiseMiddleware",
|
|
|
|
"django.contrib.sessions.middleware.SessionMiddleware",
|
|
|
|
"babybuddy.middleware.RollingSessionMiddleware",
|
|
|
|
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
|
|
|
"babybuddy.middleware.UserTimezoneMiddleware",
|
|
|
|
"django.middleware.locale.LocaleMiddleware",
|
|
|
|
"babybuddy.middleware.UserLanguageMiddleware",
|
|
|
|
"django.middleware.common.CommonMiddleware",
|
|
|
|
"django.middleware.csrf.CsrfViewMiddleware",
|
|
|
|
"django.contrib.messages.middleware.MessageMiddleware",
|
|
|
|
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
|
|
|
"axes.middleware.AxesMiddleware",
|
2023-06-04 13:26:17 +00:00
|
|
|
"babybuddy.middleware.HomeAssistant",
|
2017-08-11 18:32:02 +00:00
|
|
|
]
|
|
|
|
|
2017-08-19 14:16:51 +00:00
|
|
|
|
|
|
|
# URL dispatcher
|
2024-01-14 04:22:08 +00:00
|
|
|
# https://docs.djangoproject.com/en/5.0/topics/http/urls/
|
2017-08-19 14:16:51 +00:00
|
|
|
|
2022-02-10 00:00:30 +00:00
|
|
|
ROOT_URLCONF = "babybuddy.urls"
|
2017-08-11 18:32:02 +00:00
|
|
|
|
2017-08-19 14:16:51 +00:00
|
|
|
|
|
|
|
# Templates
|
2024-01-14 04:22:08 +00:00
|
|
|
# https://docs.djangoproject.com/en/5.0/ref/settings/#std:setting-TEMPLATES
|
2017-08-19 14:16:51 +00:00
|
|
|
|
2017-08-11 18:32:02 +00:00
|
|
|
TEMPLATES = [
|
|
|
|
{
|
2022-02-10 00:00:30 +00:00
|
|
|
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
2023-05-03 00:33:31 +00:00
|
|
|
"DIRS": ["babybuddy/templates", "babybuddy/templates/error"],
|
2022-02-10 00:00:30 +00:00
|
|
|
"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",
|
2017-08-11 18:32:02 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2020-06-09 14:11:25 +00:00
|
|
|
# Database
|
2024-01-14 04:22:08 +00:00
|
|
|
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
|
2020-06-09 14:11:25 +00:00
|
|
|
|
2021-08-06 21:28:45 +00:00
|
|
|
config = {
|
2022-02-10 00:00:30 +00:00
|
|
|
"ENGINE": os.getenv("DB_ENGINE") or "django.db.backends.sqlite3",
|
|
|
|
"NAME": os.getenv("DB_NAME") or os.path.join(BASE_DIR, "data/db.sqlite3"),
|
2021-08-06 21:28:45 +00:00
|
|
|
}
|
2022-02-10 00:00:30 +00:00
|
|
|
if os.getenv("DB_USER"):
|
|
|
|
config["USER"] = os.getenv("DB_USER")
|
|
|
|
if os.environ.get("DB_PASSWORD") or os.environ.get("POSTGRES_PASSWORD"):
|
|
|
|
config["PASSWORD"] = os.environ.get("DB_PASSWORD") or os.environ.get(
|
|
|
|
"POSTGRES_PASSWORD"
|
|
|
|
)
|
|
|
|
if os.getenv("DB_HOST"):
|
|
|
|
config["HOST"] = os.getenv("DB_HOST")
|
|
|
|
if os.getenv("DB_PORT"):
|
|
|
|
config["PORT"] = os.getenv("DB_PORT")
|
2024-01-06 11:39:18 +00:00
|
|
|
if os.getenv("DB_OPTIONS"):
|
|
|
|
config["OPTIONS"] = os.getenv("DB_OPTIONS")
|
2021-08-06 15:52:51 +00:00
|
|
|
|
2022-02-10 00:00:30 +00:00
|
|
|
DATABASES = {"default": config}
|
2020-06-09 14:11:25 +00:00
|
|
|
|
|
|
|
|
2020-01-29 04:45:37 +00:00
|
|
|
# Cache
|
2024-01-14 04:22:08 +00:00
|
|
|
# https://docs.djangoproject.com/en/5.0/topics/cache/
|
2020-01-29 04:45:37 +00:00
|
|
|
|
|
|
|
CACHES = {
|
2022-02-10 00:00:30 +00:00
|
|
|
"default": {
|
|
|
|
"BACKEND": "django.core.cache.backends.db.DatabaseCache",
|
|
|
|
"LOCATION": "cache_default",
|
2020-01-29 04:45:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-08-19 14:16:51 +00:00
|
|
|
# WGSI
|
2024-01-14 04:22:08 +00:00
|
|
|
# https://docs.djangoproject.com/en/5.0/howto/deployment/wsgi/
|
2017-08-11 18:32:02 +00:00
|
|
|
|
2022-02-10 00:00:30 +00:00
|
|
|
WSGI_APPLICATION = "babybuddy.wsgi.application"
|
2017-08-11 18:32:02 +00:00
|
|
|
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
# Authentication
|
2024-01-14 04:22:08 +00:00
|
|
|
# https://docs.djangoproject.com/en/5.0/topics/auth/default/
|
2017-08-16 16:46:26 +00:00
|
|
|
|
2021-06-22 03:41:23 +00:00
|
|
|
AUTHENTICATION_BACKENDS = [
|
2022-02-10 00:00:30 +00:00
|
|
|
"axes.backends.AxesBackend",
|
|
|
|
"django.contrib.auth.backends.ModelBackend",
|
2021-06-22 03:41:23 +00:00
|
|
|
]
|
|
|
|
|
2022-02-10 00:00:30 +00:00
|
|
|
LOGIN_REDIRECT_URL = "babybuddy:root-router"
|
2017-08-16 16:46:26 +00:00
|
|
|
|
2022-02-10 00:00:30 +00:00
|
|
|
LOGIN_URL = "babybuddy:login"
|
2017-08-16 16:46:26 +00:00
|
|
|
|
2022-02-10 00:00:30 +00:00
|
|
|
LOGOUT_REDIRECT_URL = "babybuddy:login"
|
2017-08-16 16:46:26 +00:00
|
|
|
|
2022-09-18 21:00:41 +00:00
|
|
|
REVERSE_PROXY_AUTH = bool(strtobool(os.environ.get("REVERSE_PROXY_AUTH") or "False"))
|
|
|
|
|
|
|
|
# Use remote user middleware when reverse proxy auth is enabled.
|
|
|
|
if REVERSE_PROXY_AUTH:
|
|
|
|
# Must appear AFTER AuthenticationMiddleware.
|
|
|
|
MIDDLEWARE.append("babybuddy.middleware.CustomRemoteUser")
|
|
|
|
AUTHENTICATION_BACKENDS.append("django.contrib.auth.backends.RemoteUserBackend")
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
|
2020-01-20 23:09:58 +00:00
|
|
|
# Timezone
|
2024-01-14 04:22:08 +00:00
|
|
|
# https://docs.djangoproject.com/en/5.0/topics/i18n/timezones/
|
2017-08-11 18:32:02 +00:00
|
|
|
|
2020-01-20 23:09:58 +00:00
|
|
|
USE_TZ = True
|
2017-08-11 18:32:02 +00:00
|
|
|
|
2022-06-11 21:27:52 +00:00
|
|
|
TIME_ZONE = "UTC"
|
2017-08-11 18:32:02 +00:00
|
|
|
|
2020-01-20 23:09:58 +00:00
|
|
|
# Internationalization
|
2024-01-14 04:22:08 +00:00
|
|
|
# https://docs.djangoproject.com/en/5.0/topics/i18n/
|
2017-08-11 18:32:02 +00:00
|
|
|
|
2020-01-20 23:09:58 +00:00
|
|
|
USE_I18N = True
|
2017-08-11 18:32:02 +00:00
|
|
|
|
2022-02-10 00:00:30 +00:00
|
|
|
LANGUAGE_CODE = "en-US"
|
2017-08-11 18:32:02 +00:00
|
|
|
|
2019-04-14 02:13:14 +00:00
|
|
|
LOCALE_PATHS = [
|
|
|
|
os.path.join(BASE_DIR, "locale"),
|
2019-04-14 03:09:55 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
LANGUAGES = [
|
2022-04-10 21:40:15 +00:00
|
|
|
("ca", _("Catalan")),
|
2023-02-11 19:21:26 +00:00
|
|
|
("cs", _("Czech")),
|
2022-02-21 17:27:27 +00:00
|
|
|
("zh-hans", _("Chinese (simplified)")),
|
2023-02-11 19:21:26 +00:00
|
|
|
("da", _("Danish")),
|
2022-02-21 17:27:27 +00:00
|
|
|
("nl", _("Dutch")),
|
2022-02-10 00:00:30 +00:00
|
|
|
("en-US", _("English (US)")),
|
|
|
|
("en-GB", _("English (UK)")),
|
|
|
|
("fr", _("French")),
|
|
|
|
("fi", _("Finnish")),
|
|
|
|
("de", _("German")),
|
2023-02-11 19:21:26 +00:00
|
|
|
("hu", _("Hungarian")),
|
2022-02-10 00:00:30 +00:00
|
|
|
("it", _("Italian")),
|
2023-05-03 01:53:16 +00:00
|
|
|
("nb", _("Norwegian Bokmål")),
|
2022-02-10 00:00:30 +00:00
|
|
|
("pl", _("Polish")),
|
|
|
|
("pt", _("Portuguese")),
|
2023-02-11 19:21:26 +00:00
|
|
|
("ru", _("Russian")),
|
2022-02-10 00:00:30 +00:00
|
|
|
("es", _("Spanish")),
|
|
|
|
("sv", _("Swedish")),
|
|
|
|
("tr", _("Turkish")),
|
2019-04-14 02:13:14 +00:00
|
|
|
]
|
|
|
|
|
2017-08-11 18:32:02 +00:00
|
|
|
|
2020-01-20 23:09:58 +00:00
|
|
|
# Format localization
|
2024-01-14 04:22:08 +00:00
|
|
|
# https://docs.djangoproject.com/en/5.0/topics/i18n/formatting/
|
2020-01-20 23:09:58 +00:00
|
|
|
|
2023-02-12 01:39:36 +00:00
|
|
|
FORMAT_MODULE_PATH = ["babybuddy.formats"]
|
|
|
|
|
2020-01-20 23:09:58 +00:00
|
|
|
|
2024-01-14 04:22:08 +00:00
|
|
|
# Storage
|
|
|
|
# https://docs.djangoproject.com/en/5.0/ref/files/storage/
|
|
|
|
# https://docs.djangoproject.com/en/5.0/ref/settings/#std-setting-STORAGES
|
|
|
|
|
|
|
|
STORAGES = {
|
|
|
|
"default": {"BACKEND": "django.core.files.storage.FileSystemStorage"},
|
|
|
|
"staticfiles": {
|
|
|
|
"BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-08-11 18:32:02 +00:00
|
|
|
# Static files (CSS, JavaScript, Images)
|
2024-01-14 04:22:08 +00:00
|
|
|
# https://docs.djangoproject.com/en/5.0/howto/static-files/
|
2020-01-19 16:49:45 +00:00
|
|
|
# http://whitenoise.evans.io/en/stable/django.html
|
2017-08-11 18:32:02 +00:00
|
|
|
|
2017-10-23 09:07:35 +00:00
|
|
|
STATICFILES_FINDERS = [
|
2022-02-10 00:00:30 +00:00
|
|
|
"django.contrib.staticfiles.finders.FileSystemFinder",
|
|
|
|
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
|
2017-10-23 09:07:35 +00:00
|
|
|
]
|
|
|
|
|
2022-02-26 23:55:16 +00:00
|
|
|
STATIC_URL = os.path.join(os.environ.get("SUB_PATH") or "", "static/")
|
2017-08-13 13:44:48 +00:00
|
|
|
|
2022-02-10 00:00:30 +00:00
|
|
|
STATIC_ROOT = os.path.join(BASE_DIR, "static")
|
2017-08-19 13:50:03 +00:00
|
|
|
|
2022-02-10 00:00:30 +00:00
|
|
|
WHITENOISE_ROOT = os.path.join(BASE_DIR, "static", "babybuddy", "root")
|
2018-02-25 06:13:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Media files (User uploaded content)
|
2024-01-14 04:22:08 +00:00
|
|
|
# https://docs.djangoproject.com/en/5.0/topics/files/
|
2018-02-25 06:13:39 +00:00
|
|
|
|
2022-02-10 00:00:30 +00:00
|
|
|
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
|
2017-11-18 09:22:12 +00:00
|
|
|
|
2022-02-10 00:00:30 +00:00
|
|
|
MEDIA_URL = "media/"
|
2018-02-25 06:13:39 +00:00
|
|
|
|
2022-02-10 00:00:30 +00:00
|
|
|
AWS_STORAGE_BUCKET_NAME = os.environ.get("AWS_STORAGE_BUCKET_NAME") or None
|
2018-02-25 06:13:39 +00:00
|
|
|
|
2022-02-10 00:00:30 +00:00
|
|
|
AWS_ACCESS_KEY_ID = os.environ.get("AWS_ACCESS_KEY_ID") or None
|
2018-02-25 06:13:39 +00:00
|
|
|
|
2022-02-10 00:00:30 +00:00
|
|
|
AWS_SECRET_ACCESS_KEY = os.environ.get("AWS_SECRET_ACCESS_KEY") or None
|
2018-02-25 06:13:39 +00:00
|
|
|
|
2022-06-06 20:34:22 +00:00
|
|
|
AWS_S3_ENDPOINT_URL = os.environ.get("AWS_S3_ENDPOINT_URL") or None
|
|
|
|
|
2018-02-25 06:13:39 +00:00
|
|
|
if AWS_STORAGE_BUCKET_NAME:
|
2024-01-14 04:22:08 +00:00
|
|
|
STORAGES["default"]["BACKEND"] = "storages.backends.s3boto3.S3Boto3Storage"
|
2017-10-23 19:13:11 +00:00
|
|
|
|
2017-08-13 13:44:48 +00:00
|
|
|
|
2022-07-30 21:22:34 +00:00
|
|
|
# Email
|
2024-01-14 04:22:08 +00:00
|
|
|
# https://docs.djangoproject.com/en/5.0/topics/email/
|
2022-07-30 21:22:34 +00:00
|
|
|
|
|
|
|
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
|
|
|
EMAIL_SUBJECT_PREFIX = "[Baby Buddy] "
|
|
|
|
EMAIL_TIMEOUT = 30
|
|
|
|
if os.environ.get("EMAIL_HOST"):
|
|
|
|
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
|
|
|
|
EMAIL_HOST = os.environ.get("EMAIL_HOST")
|
|
|
|
EMAIL_HOST_USER = os.environ.get("EMAIL_HOST_USER") or ""
|
|
|
|
EMAIL_HOST_PASSWORD = os.environ.get("EMAIL_HOST_PASSWORD") or ""
|
|
|
|
EMAIL_PORT = os.environ.get("EMAIL_PORT") or 25
|
|
|
|
EMAIL_USE_TLS = bool(strtobool(os.environ.get("EMAIL_USE_TLS") or "False"))
|
|
|
|
EMAIL_USE_SSL = bool(strtobool(os.environ.get("EMAIL_USE_SSL") or "False"))
|
|
|
|
EMAIL_SSL_KEYFILE = os.environ.get("EMAIL_SSL_KEYFILE") or None
|
|
|
|
EMAIL_SSL_CERTFILE = os.environ.get("EMAIL_SSL_CERTFILE") or None
|
|
|
|
|
|
|
|
|
2021-09-17 01:59:25 +00:00
|
|
|
# Security
|
|
|
|
|
2024-01-14 04:22:08 +00:00
|
|
|
# https://docs.djangoproject.com/en/5.0/ref/settings/#secure-proxy-ssl-header
|
2022-02-10 00:00:30 +00:00
|
|
|
if os.environ.get("SECURE_PROXY_SSL_HEADER"):
|
|
|
|
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
|
2021-09-17 01:59:25 +00:00
|
|
|
|
2024-01-14 04:22:08 +00:00
|
|
|
# https://docs.djangoproject.com/en/5.0/topics/http/sessions/#settings
|
2021-09-17 02:37:04 +00:00
|
|
|
SESSION_COOKIE_HTTPONLY = True
|
2022-11-24 02:38:58 +00:00
|
|
|
SESSION_COOKIE_SECURE = bool(
|
|
|
|
strtobool(os.environ.get("SESSION_COOKIE_SECURE") or "False")
|
|
|
|
)
|
2021-09-17 02:14:48 +00:00
|
|
|
|
2024-01-14 04:22:08 +00:00
|
|
|
# https://docs.djangoproject.com/en/5.0/ref/csrf/#settings
|
2021-09-17 02:37:04 +00:00
|
|
|
CSRF_COOKIE_HTTPONLY = True
|
2022-11-24 02:26:05 +00:00
|
|
|
CSRF_COOKIE_SECURE = bool(strtobool(os.environ.get("CSRF_COOKIE_SECURE") or "False"))
|
2022-02-22 05:26:12 +00:00
|
|
|
CSRF_FAILURE_VIEW = "babybuddy.views.csrf_failure"
|
2022-02-21 23:43:43 +00:00
|
|
|
CSRF_TRUSTED_ORIGINS = list(
|
|
|
|
filter(None, os.environ.get("CSRF_TRUSTED_ORIGINS", "").split(","))
|
|
|
|
)
|
2021-09-17 01:59:25 +00:00
|
|
|
|
2022-02-21 23:39:38 +00:00
|
|
|
|
2024-01-14 04:22:08 +00:00
|
|
|
# https://docs.djangoproject.com/en/5.0/topics/auth/passwords/
|
2021-09-17 02:14:48 +00:00
|
|
|
AUTH_PASSWORD_VALIDATORS = [
|
|
|
|
{
|
2022-02-10 00:00:30 +00:00
|
|
|
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
|
2021-09-17 02:14:48 +00:00
|
|
|
},
|
|
|
|
{
|
2022-02-10 00:00:30 +00:00
|
|
|
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
|
|
|
|
"OPTIONS": {
|
|
|
|
"min_length": 8,
|
|
|
|
},
|
2021-09-17 02:14:48 +00:00
|
|
|
},
|
|
|
|
{
|
2022-02-10 00:00:30 +00:00
|
|
|
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
|
2021-09-17 02:14:48 +00:00
|
|
|
},
|
|
|
|
{
|
2022-02-10 00:00:30 +00:00
|
|
|
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
|
2021-09-17 02:14:48 +00:00
|
|
|
},
|
|
|
|
]
|
2021-09-17 01:59:25 +00:00
|
|
|
|
2017-08-13 13:44:48 +00:00
|
|
|
# Django Rest Framework
|
2020-01-19 16:49:45 +00:00
|
|
|
# https://www.django-rest-framework.org/
|
2017-08-19 14:16:51 +00:00
|
|
|
|
2017-08-13 13:44:48 +00:00
|
|
|
REST_FRAMEWORK = {
|
2022-02-10 00:00:30 +00:00
|
|
|
"DEFAULT_AUTHENTICATION_CLASSES": [
|
|
|
|
"rest_framework.authentication.SessionAuthentication",
|
|
|
|
"rest_framework.authentication.TokenAuthentication",
|
2017-11-02 10:05:12 +00:00
|
|
|
],
|
2022-02-10 00:00:30 +00:00
|
|
|
"DEFAULT_FILTER_BACKENDS": [
|
|
|
|
"django_filters.rest_framework.DjangoFilterBackend",
|
2023-02-10 16:28:11 +00:00
|
|
|
"rest_framework.filters.OrderingFilter",
|
2017-08-20 17:31:19 +00:00
|
|
|
],
|
2022-02-10 00:00:30 +00:00
|
|
|
"DEFAULT_METADATA_CLASS": "api.metadata.APIMetadata",
|
|
|
|
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.LimitOffsetPagination",
|
|
|
|
"DEFAULT_PERMISSION_CLASSES": ["api.permissions.BabyBuddyDjangoModelPermissions"],
|
|
|
|
"DEFAULT_RENDERER_CLASSES": [
|
|
|
|
"rest_framework.renderers.JSONRenderer",
|
2017-11-02 10:05:12 +00:00
|
|
|
],
|
2022-02-10 00:00:30 +00:00
|
|
|
"PAGE_SIZE": 100,
|
2017-08-13 13:44:48 +00:00
|
|
|
}
|
2017-11-04 11:59:28 +00:00
|
|
|
|
2020-02-16 23:58:49 +00:00
|
|
|
# Import/Export configuration
|
|
|
|
# See https://django-import-export.readthedocs.io/
|
|
|
|
|
2022-02-10 00:00:30 +00:00
|
|
|
IMPORT_EXPORT_IMPORT_PERMISSION_CODE = "add"
|
2021-06-22 03:41:23 +00:00
|
|
|
|
2022-02-10 00:00:30 +00:00
|
|
|
IMPORT_EXPORT_EXPORT_PERMISSION_CODE = "change"
|
2021-06-22 03:41:23 +00:00
|
|
|
|
2020-02-17 18:34:31 +00:00
|
|
|
IMPORT_EXPORT_USE_TRANSACTIONS = True
|
2020-02-16 23:58:49 +00:00
|
|
|
|
2021-06-22 03:41:23 +00:00
|
|
|
# Axes configuration
|
|
|
|
# See https://django-axes.readthedocs.io/en/latest/4_configuration.html
|
|
|
|
|
|
|
|
AXES_COOLOFF_TIME = 1
|
|
|
|
|
|
|
|
AXES_FAILURE_LIMIT = 5
|
|
|
|
|
2023-02-11 17:02:23 +00:00
|
|
|
AXES_LOCKOUT_TEMPLATE = "error/lockout.html"
|
|
|
|
|
|
|
|
AXES_LOCKOUT_URL = "/login/lock"
|
|
|
|
|
2020-06-09 14:11:25 +00:00
|
|
|
# Session configuration
|
|
|
|
# Used by RollingSessionMiddleware to determine how often to reset the session.
|
2022-02-21 23:39:38 +00:00
|
|
|
# See https://docs.djangoproject.com/en/4.0/topics/http/sessions/
|
2020-06-09 14:11:25 +00:00
|
|
|
|
2020-05-17 06:57:00 +00:00
|
|
|
ROLLING_SESSION_REFRESH = 86400
|
|
|
|
|
2021-04-11 19:49:15 +00:00
|
|
|
# Set default auto field for models.
|
2024-01-14 04:22:08 +00:00
|
|
|
# See https://docs.djangoproject.com/en/5.0/releases/3.2/#customizing-type-of-auto-created-primary-keys
|
2021-06-22 03:41:23 +00:00
|
|
|
|
2022-02-10 00:00:30 +00:00
|
|
|
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
|
2021-04-11 19:49:15 +00:00
|
|
|
|
2017-11-04 11:59:28 +00:00
|
|
|
# Baby Buddy configuration
|
2023-06-04 13:26:17 +00:00
|
|
|
# See https://docs.baby-buddy.net/ for details about these settings.
|
2017-11-04 11:59:28 +00:00
|
|
|
|
|
|
|
BABY_BUDDY = {
|
2022-02-10 00:00:30 +00:00
|
|
|
"ALLOW_UPLOADS": bool(strtobool(os.environ.get("ALLOW_UPLOADS") or "True")),
|
2023-02-11 18:31:14 +00:00
|
|
|
"READ_ONLY_GROUP_NAME": "read_only",
|
2017-11-04 11:59:28 +00:00
|
|
|
}
|
2023-06-04 13:26:17 +00:00
|
|
|
|
|
|
|
# Home assistant specific configuration
|
|
|
|
|
2023-07-04 22:21:34 +00:00
|
|
|
ENABLE_HOME_ASSISTANT_SUPPORT = bool(
|
|
|
|
strtobool(os.environ.get("ENABLE_HOME_ASSISTANT_SUPPORT") or "False")
|
|
|
|
)
|