Coverage for sample_project/settings.py: 100%
20 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-16 07:42 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-16 07:42 +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_relations",
48 "apis_core.apis_entities",
49 # apis_vocabularies is deprecated, but there are
50 # still migrations depending on it - it will be dropped
51 # at some point
52 "apis_core.apis_vocabularies",
53 # APIS collections provide a collection model similar to
54 # SKOS collections and allow tagging of content
55 "apis_core.collections",
56 # APIS history modules tracks changes of instances over
57 # time and lets you revert changes
58 "apis_core.history",
59 # The core APIS apps come last, so other apps can override
60 # and extend their templates
61 "apis_core.generic",
62 "apis_core.core",
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]
76# ROOT_URLCONF = "apis_core.urls"
77ROOT_URLCONF = "sample_project.urls"
79TEMPLATES = [
80 {
81 "BACKEND": "django.template.backends.django.DjangoTemplates",
82 "DIRS": [],
83 "APP_DIRS": True,
84 "OPTIONS": {
85 "context_processors": [
86 "django.template.context_processors.debug",
87 "django.template.context_processors.request",
88 "django.contrib.auth.context_processors.auth",
89 "django.contrib.messages.context_processors.messages",
90 ],
91 },
92 },
93]
95STATIC_URL = "/static/"
96STATIC_ROOT = "/tmp/staticfiles"
98PROJECT_DEFAULT_MD = {}
100DATABASES = {
101 "default": {
102 "ENGINE": "django.db.backends.sqlite3",
103 "NAME": "/tmp/db.sqlite3",
104 },
105}
107CRISPY_TEMPLATE_PACK = "bootstrap4"
108DJANGO_TABLES2_TEMPLATE = "django_tables2/bootstrap4.html"
110# for django spectacular to be able to generate the schema, we have to use its view inspector
111REST_FRAMEWORK = {"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema"}
112# we use our custom schema generator to make it pick up our custom routes
113SPECTACULAR_SETTINGS = {
114 "DEFAULT_GENERATOR_CLASS": "apis_core.generic.generators.CustomSchemaGenerator"
115}