Coverage for sample_project/settings.py: 100%
20 statements
« prev ^ index » next coverage.py v7.6.8, created at 2024-12-20 09:24 +0000
« prev ^ index » next coverage.py v7.6.8, created at 2024-12-20 09:24 +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 # `apis_override_select2js` is a workaround for APIS'
23 # handling of autocomplete forms. It should be listed
24 # at the beginning of the list, to make sure the
25 # files shipped with it are served in precedence.
26 "apis_override_select2js",
27 "django.contrib.admin",
28 "django.contrib.auth",
29 "django.contrib.contenttypes",
30 "django.contrib.sessions",
31 "django.contrib.messages",
32 "django.contrib.staticfiles",
33 # ui stuff used by APIS
34 "crispy_forms",
35 "crispy_bootstrap4",
36 "django_filters",
37 "django_tables2",
38 "dal",
39 "dal_select2",
40 # REST API
41 "rest_framework",
42 # swagger ui generation
43 "drf_spectacular",
44 # The APIS apps
45 "apis_core.relations",
46 "apis_core.apis_metainfo",
47 "apis_core.apis_entities",
48 # apis_vocabularies is deprecated, but there are
49 # still migrations depending on it - it will be dropped
50 # at some point
51 "apis_core.apis_vocabularies",
52 # APIS collections provide a collection model similar to
53 # SKOS collections and allow tagging of content
54 "apis_core.collections",
55 # APIS history modules tracks changes of instances over
56 # time and lets you revert changes
57 "apis_core.history",
58 # The core APIS apps come last, so other apps can override
59 # and extend their templates
60 "apis_core.generic",
61 "apis_core.core",
62 "apis_core.documentation",
63]
65MIDDLEWARE = [
66 "django.middleware.security.SecurityMiddleware",
67 "django.contrib.sessions.middleware.SessionMiddleware",
68 "django.middleware.common.CommonMiddleware",
69 "django.middleware.csrf.CsrfViewMiddleware",
70 "django.contrib.auth.middleware.AuthenticationMiddleware",
71 "django.contrib.messages.middleware.MessageMiddleware",
72 "django.middleware.clickjacking.XFrameOptionsMiddleware",
73 "crum.CurrentRequestUserMiddleware",
74 "simple_history.middleware.HistoryRequestMiddleware",
75]
77# ROOT_URLCONF = "apis_core.urls"
78ROOT_URLCONF = "sample_project.urls"
80TEMPLATES = [
81 {
82 "BACKEND": "django.template.backends.django.DjangoTemplates",
83 "DIRS": [],
84 "APP_DIRS": True,
85 "OPTIONS": {
86 "context_processors": [
87 "django.template.context_processors.debug",
88 "django.template.context_processors.request",
89 "django.contrib.auth.context_processors.auth",
90 "django.contrib.messages.context_processors.messages",
91 ],
92 },
93 },
94]
96STATIC_URL = "/static/"
97STATIC_ROOT = "/tmp/staticfiles"
99DATABASES = {
100 "default": {
101 "ENGINE": "django.db.backends.sqlite3",
102 "NAME": "/tmp/db.sqlite3",
103 },
104}
106CRISPY_TEMPLATE_PACK = "bootstrap4"
107DJANGO_TABLES2_TEMPLATE = "django_tables2/bootstrap4.html"
109# for django spectacular to be able to generate the schema, we have to use its view inspector
110REST_FRAMEWORK = {"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema"}
111# we use our custom schema generator to make it pick up our custom routes
112SPECTACULAR_SETTINGS = {
113 "DEFAULT_GENERATOR_CLASS": "apis_core.generic.generators.CustomSchemaGenerator"
114}
116LOGGING = {
117 "version": 1,
118 "disable_existing_loggers": False,
119 "formatters": {
120 "verbose": {
121 "format": "%(asctime)s %(name)-6s %(levelname)-8s %(message)s",
122 },
123 },
124 "handlers": {
125 "console": {
126 "class": "logging.StreamHandler",
127 "formatter": "verbose",
128 },
129 },
130 "root": {
131 "handlers": ["console"],
132 "level": "DEBUG",
133 },
134}