Coverage for sample_project/settings.py: 100%
21 statements
« prev ^ index » next coverage.py v7.5.3, created at 2025-09-17 09:41 +0000
« prev ^ index » next coverage.py v7.5.3, created at 2025-09-17 09:41 +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.relations",
47 "apis_core.history",
48 "apis_core.apis_entities",
49 # APIS history modules tracks changes of instances over
50 # time and lets you revert changes
51 # The core APIS apps come last, so other apps can override
52 # and extend their templates
53 "apis_core.core",
54 "apis_core.documentation",
55]
57MIDDLEWARE = [
58 "django.middleware.security.SecurityMiddleware",
59 "django.contrib.sessions.middleware.SessionMiddleware",
60 "django.middleware.locale.LocaleMiddleware",
61 "django.middleware.common.CommonMiddleware",
62 "django.middleware.csrf.CsrfViewMiddleware",
63 "django.contrib.auth.middleware.AuthenticationMiddleware",
64 "django.contrib.messages.middleware.MessageMiddleware",
65 "django.middleware.clickjacking.XFrameOptionsMiddleware",
66 "crum.CurrentRequestUserMiddleware",
67 "simple_history.middleware.HistoryRequestMiddleware",
68 "apis_core.generic.middleware.HtmxMessageMiddleware",
69]
71# ROOT_URLCONF = "apis_core.urls"
72ROOT_URLCONF = "sample_project.urls"
74TEMPLATES = [
75 {
76 "BACKEND": "django.template.backends.django.DjangoTemplates",
77 "DIRS": [],
78 "APP_DIRS": True,
79 "OPTIONS": {
80 "context_processors": [
81 "django.template.context_processors.debug",
82 "django.template.context_processors.request",
83 "django.contrib.auth.context_processors.auth",
84 "django.contrib.messages.context_processors.messages",
85 ],
86 },
87 },
88]
90STATIC_URL = "/static/"
91STATIC_ROOT = "/tmp/staticfiles"
93DATABASES = {
94 "default": {
95 "ENGINE": "django.db.backends.sqlite3",
96 "NAME": "/tmp/db.sqlite3",
97 },
98}
100CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap5"
101CRISPY_TEMPLATE_PACK = "bootstrap5"
102DJANGO_TABLES2_TEMPLATE = "django_tables2/bootstrap5.html"
104# for django spectacular to be able to generate the schema, we have to use its view inspector
105REST_FRAMEWORK = {"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema"}
106# we use our custom schema generator to make it pick up our custom routes
107SPECTACULAR_SETTINGS = {
108 "DEFAULT_GENERATOR_CLASS": "apis_core.generic.generators.CustomSchemaGenerator"
109}
111LOGGING = {
112 "version": 1,
113 "disable_existing_loggers": False,
114 "formatters": {
115 "verbose": {
116 "format": "%(asctime)s %(name)-6s %(levelname)-8s %(message)s",
117 },
118 },
119 "handlers": {
120 "console": {
121 "class": "logging.StreamHandler",
122 "formatter": "verbose",
123 },
124 },
125 "root": {
126 "handlers": ["console"],
127 "level": "DEBUG",
128 },
129}