Coverage for sample_project / settings.py: 100%
21 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-05-05 11:37 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-05-05 11:37 +0000
1import os
3from django.core.management.utils import get_random_secret_key
5SECRET_KEY = os.environ.get("SECRET_KEY", get_random_secret_key())
6DEBUG = True
8# we look for values in the environment and fallback to the
9# Django defaults if there are none set
10env_ah = os.environ.get("DJANGO_ALLOWED_HOSTS", "").split(",")
11ALLOWED_HOSTS = list(filter(None, env_ah))
12env_csrf = os.environ.get("DJANGO_CSRF_TRUSTED_ORIGINS", "").split(",")
13CSRF_TRUSTED_ORIGINS = list(filter(None, env_csrf))
16# Application definition
18INSTALLED_APPS = [
19 # our main app, containing the ontology (in the `models.py`)
20 # and our customizations
21 "sample_project",
22 "django.contrib.admin",
23 "django.contrib.auth",
24 "django.contrib.contenttypes",
25 "django.contrib.sessions",
26 "django.contrib.messages",
27 "django.contrib.staticfiles",
28 # ui stuff used by APIS
29 "crispy_forms",
30 "crispy_bootstrap5",
31 "django_filters",
32 "django_tables2",
33 "dal",
34 "dal_select2",
35 # REST API
36 "rest_framework",
37 # swagger ui generation
38 "drf_spectacular",
39 # The APIS apps
40 "apis_core.generic",
41 # APIS collections provide a collection model similar to
42 # SKOS collections and allow tagging of content
43 "apis_core.collections",
44 "apis_core.apis_metainfo",
45 "apis_core.uris",
46 "apis_core.entities",
47 "apis_core.relations",
48 "apis_core.history",
49 "apis_core.apis_entities",
50 # APIS history modules tracks changes of instances over
51 # time and lets you revert changes
52 # The core APIS apps come last, so other apps can override
53 # and extend their templates
54 "apis_core.core",
55 "apis_core.documentation",
56]
58MIDDLEWARE = [
59 "django.middleware.security.SecurityMiddleware",
60 "django.contrib.sessions.middleware.SessionMiddleware",
61 "django.middleware.locale.LocaleMiddleware",
62 "django.middleware.common.CommonMiddleware",
63 "django.middleware.csrf.CsrfViewMiddleware",
64 "django.contrib.auth.middleware.AuthenticationMiddleware",
65 "django.contrib.messages.middleware.MessageMiddleware",
66 "django.middleware.clickjacking.XFrameOptionsMiddleware",
67 "crum.CurrentRequestUserMiddleware",
68 "simple_history.middleware.HistoryRequestMiddleware",
69 "apis_core.generic.middleware.HtmxMessageMiddleware",
70]
72# ROOT_URLCONF = "apis_core.urls"
73ROOT_URLCONF = "sample_project.urls"
75TEMPLATES = [
76 {
77 "BACKEND": "django.template.backends.django.DjangoTemplates",
78 "DIRS": [],
79 "APP_DIRS": True,
80 "OPTIONS": {
81 "context_processors": [
82 "django.template.context_processors.debug",
83 "django.template.context_processors.request",
84 "django.contrib.auth.context_processors.auth",
85 "django.contrib.messages.context_processors.messages",
86 ],
87 },
88 },
89]
91STATIC_URL = "/static/"
92STATIC_ROOT = "/tmp/staticfiles"
94DATABASES = {
95 "default": {
96 "ENGINE": "django.db.backends.sqlite3",
97 "NAME": "/tmp/db.sqlite3",
98 },
99}
101CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap5"
102CRISPY_TEMPLATE_PACK = "bootstrap5"
103DJANGO_TABLES2_TEMPLATE = "django_tables2/bootstrap5.html"
105# for django spectacular to be able to generate the schema, we have to use its view inspector
106REST_FRAMEWORK = {"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema"}
107# we use our custom schema generator to make it pick up our custom routes
108SPECTACULAR_SETTINGS = {
109 "DEFAULT_GENERATOR_CLASS": "apis_core.generic.generators.CustomSchemaGenerator"
110}
112LOGGING = {
113 "version": 1,
114 "disable_existing_loggers": False,
115 "formatters": {
116 "verbose": {
117 "format": "%(asctime)s %(name)-6s %(levelname)-8s %(message)s",
118 },
119 },
120 "handlers": {
121 "console": {
122 "class": "logging.StreamHandler",
123 "formatter": "verbose",
124 },
125 },
126 "root": {
127 "handlers": ["console"],
128 "level": "DEBUG",
129 },
130}