module documentation

Django settings module that defines important configurations. For an explanation of all the listed values, see the official Django documentation.

Generally, the most important settings - but also as few as possible - should be fetched from environment variables. The settings are written such that errors are thrown when the required env vars are not present. This is by design, to ensure the host environment is configured for the application.

Only these env vars should need to be changed:

  • DJANGO_ENV can take on the values "debug", "maintenance", or "production".
  • DJANGO_SECRET_KEY must contain the secret key for Django's security stuff.
  • DJANGO_ALLOWED_HOSTS needs to contain the allowed host names separated by spaces.
  • DJANGO_LOG_LEVEL for the log level. This only has an effect in debug mode.
  • DJANGO_BASE_DIR is the directory in which Django is based.
Function set_LOGGING Return logging settings in the form of a dictionary as function of the log-level. This is used so that in a subdomain settings file the function can be called again to overwrite the logging settings easily.
Constant ALLOWED_HOSTS Space-separated list of hostnames for which django will accept requests. Can be set with the env var DJANGO_ALLOWED_HOSTS.
Constant AUTH_PASSWORD_VALIDATORS Undocumented
Constant AUTH_USER_MODEL Undocumented
Constant BASE_DIR Setting the base dir manually is necessary, because otherwise everything might be set up relative to venv's site-packages.
Constant CRSF_TRUSTED_ORIGINS Undocumented
Constant CSRF_COOKIE_SECURE Undocumented
Constant DATABASES Undocumented
Constant DBBACKUP_STORAGE Undocumented
Constant DBBACKUP_STORAGE_OPTIONS Undocumented
Constant DEBUG True, when in debug mode, meaning DJANGO_ENV is set to "debug".
Constant DEFAULT_AUTO_FIELD Undocumented
Constant FROZEN_VERSIONS Undocumented
Constant GITHUB Undocumented
Constant GITHUB_REPO_NAME Undocumented
Constant GITHUB_REPO_OWNER Undocumented
Constant GITHUB_TOKEN Read-only GitHub access token for fetching information about lyprox.riskpredictor.models.InferenceResult.
Constant INSTALLED_APPS Undocumented
Constant IS_FROZEN Undocumented
Constant LANGUAGE_CODE Undocumented
Constant LOG_LEVEL Set the threshold for logging event when in DEBUG mode. During "maintenance" and "production" this is fixed to "WARNING". Set via the environment variable DJANGO_LOG_LEVEL.
Constant LOGGING Undocumented
Constant LOGIN_NOT_REQUIRED_URLS List of regexes for urls that are exceptions from the LOGIN_REQUIRED_URLS.
Constant LOGIN_REDIRECT_URL Redirect to this URL after successful login.
Constant LOGIN_REQUIRED_URLS List of regexes for urls that require login.
Constant LOGIN_URL URL to redirect to when login is required.
Constant MAINTENANCE If True, all requests to are redirected to a maintenance page. DJANGO_ENV must be set to "maintenance" for this to work. Also see lyprox.views.maintenance.
Constant MEDIA_ROOT Undocumented
Constant MEDIA_URL Undocumented
Constant MIDDLEWARE Undocumented
Constant PRODUCTION Set DJANGO_ENV to "production" to disable DEBUG and MAINTENANCE modes.
Constant PUBLICATIONS_PATH Undocumented
Constant ROOT_URLCONF Undocumented
Constant SECRET_KEY Secret key for cryptographic functions. This is the most sensitive information about the application. It is set via the environment variable DJANGO_SECRET_KEY.
Constant SECURE_HSTS_INCLUDE_SUBDOMAINS Undocumented
Constant SECURE_HSTS_PRELOAD Undocumented
Constant SECURE_HSTS_SECONDS Undocumented
Constant SECURE_PROXY_SSL_HEADER Undocumented
Constant SESSION_COOKIE_SECURE Undocumented
Constant STATIC_ROOT Undocumented
Constant STATIC_URL Undocumented
Constant STATICFILES_DIRS Undocumented
Constant TEMPLATES Undocumented
Constant TIME_ZONE Undocumented
Constant USE_I18N Undocumented
Constant USE_L10N Undocumented
Constant USE_TZ Undocumented
Variable _login_required_urls_env Undocumented
def set_LOGGING(LOG_LEVEL):

Return logging settings in the form of a dictionary as function of the log-level. This is used so that in a subdomain settings file the function can be called again to overwrite the logging settings easily.

ALLOWED_HOSTS =

Space-separated list of hostnames for which django will accept requests. Can be set with the env var DJANGO_ALLOWED_HOSTS.

Value
os.environ['DJANGO_ALLOWED_HOSTS'].split(' ')
AUTH_PASSWORD_VALIDATORS: list =

Undocumented

Value
[{'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValida
tor'},
 {'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator'},
 {'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator'},
 {'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator'}]
AUTH_USER_MODEL: str =

Undocumented

Value
'accounts.User'
BASE_DIR =

Setting the base dir manually is necessary, because otherwise everything might be set up relative to venv's site-packages.

Value
Path(os.environ['DJANGO_BASE_DIR'])
CRSF_TRUSTED_ORIGINS =

Undocumented

Value
[f'https://{host}' for host in ALLOWED_HOSTS]
CSRF_COOKIE_SECURE =

Undocumented

Value
not DEBUG
DATABASES =

Undocumented

Value
{'default': {'ENGINE': 'django.db.backends.sqlite3',
             'NAME': BASE_DIR/'db.sqlite3'}}
DBBACKUP_STORAGE: str =

Undocumented

Value
'django.core.files.storage.FileSystemStorage'
DBBACKUP_STORAGE_OPTIONS: dict[str, str] =

Undocumented

Value
{'location': '/home/rmnldwg/backups/lyprox/'}
DEBUG =

True, when in debug mode, meaning DJANGO_ENV is set to "debug".

Value
(os.environ['DJANGO_ENV'] == 'debug')
DEFAULT_AUTO_FIELD: str =

Undocumented

Value
'django.db.models.AutoField'
FROZEN_VERSIONS: list =

Undocumented

Value
[{'name': '2021 oropharynx data', 'url': 'https://2021-oropharynx.lyprox.org'}]
GITHUB =

Undocumented

Value
Github(login_or_token=GITHUB_TOKEN)
GITHUB_REPO_NAME: str =

Undocumented

Value
'lyprox'
GITHUB_REPO_OWNER: str =

Undocumented

Value
'rmnldwg'
GITHUB_TOKEN =

Read-only GitHub access token for fetching information about lyprox.riskpredictor.models.InferenceResult.

Value
os.environ['GITHUB_TOKEN']
INSTALLED_APPS: list[str] =

Undocumented

Value
['lyprox.accounts.apps.AccountsConfig',
 'lyprox.patients.apps.PatientsConfig',
 'lyprox.dataexplorer.apps.DataExplorerConfig',
 'lyprox.riskpredictor.apps.RiskConfig',
 'django_filters',
 'fontawesomefree',
 'phonenumber_field',
...
IS_FROZEN: bool =

Undocumented

Value
False
LANGUAGE_CODE: str =

Undocumented

Value
'en-us'
LOG_LEVEL =

Set the threshold for logging event when in DEBUG mode. During "maintenance" and "production" this is fixed to "WARNING". Set via the environment variable DJANGO_LOG_LEVEL.

Value
(os.environ['DJANGO_LOG_LEVEL'] if DEBUG else 'WARNING')
LOGGING =

Undocumented

Value
set_LOGGING(LOG_LEVEL)
LOGIN_NOT_REQUIRED_URLS: list[str] =

List of regexes for urls that are exceptions from the LOGIN_REQUIRED_URLS.

Value
['/accounts/login/(.*)$',
 '/accounts/logout/(.*)$',
 '/admin/(.*)$',
 '/maintenance/(.*)$']
LOGIN_REDIRECT_URL: str =

Redirect to this URL after successful login.

Value
'/'
LOGIN_REQUIRED_URLS =

List of regexes for urls that require login.

Note that this may simply be left empty, since the critical views are protected by default. But if you want to protect e.g. the entire website, you can add "(.*)$" to the list.

Value
_login_required_urls_env.split(' ')
LOGIN_URL =

URL to redirect to when login is required.

Value
urls.reverse_lazy('accounts:login')
MAINTENANCE =

If True, all requests to are redirected to a maintenance page. DJANGO_ENV must be set to "maintenance" for this to work. Also see lyprox.views.maintenance.

Value
(os.environ['DJANGO_ENV'] == 'maintenance')
MEDIA_ROOT =

Undocumented

Value
BASE_DIR/'media'
MEDIA_URL: str =

Undocumented

Value
'/media/'
MIDDLEWARE: list[str] =

Undocumented

Value
['lyprox.middleware.MaintenanceMiddleware',
 'lyprox.middleware.LoginRequiredMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
...
PRODUCTION =

Set DJANGO_ENV to "production" to disable DEBUG and MAINTENANCE modes.

Value
(os.environ['DJANGO_ENV'] == 'production')
PUBLICATIONS_PATH =

Undocumented

Value
(STATIC_ROOT/'publications')/'data.yaml'
ROOT_URLCONF: str =

Undocumented

Value
'lyprox.urls'
SECRET_KEY =

Secret key for cryptographic functions. This is the most sensitive information about the application. It is set via the environment variable DJANGO_SECRET_KEY.

Value
os.environ['DJANGO_SECRET_KEY']
SECURE_HSTS_INCLUDE_SUBDOMAINS =

Undocumented

Value
not DEBUG
SECURE_HSTS_PRELOAD =

Undocumented

Value
not DEBUG
SECURE_HSTS_SECONDS =

Undocumented

Value
(30 if DEBUG else 2592000)
SECURE_PROXY_SSL_HEADER: tuple[str, ...] =

Undocumented

Value
('HTTP_X_FORWARDED_PROTO', 'https')
SESSION_COOKIE_SECURE =

Undocumented

Value
not DEBUG
STATIC_ROOT =

Undocumented

Value
BASE_DIR/'static'
STATIC_URL: str =

Undocumented

Value
'/static/'
STATICFILES_DIRS =

Undocumented

Value
[(BASE_DIR/'lyprox')/'static']
TEMPLATES =

Undocumented

Value
[{'BACKEND': 'django.template.backends.django.DjangoTemplates',
  'DIRS': [(BASE_DIR/'lyprox')/'templates'],
  'APP_DIRS': True,
  'OPTIONS': {'context_processors': ['django.template.context_processors.debug',
                                     'django.template.context_processors.request'
,
                                     'django.contrib.auth.context_processors.aut
...
TIME_ZONE: str =

Undocumented

Value
'Europe/Zurich'
USE_I18N: bool =

Undocumented

Value
True
USE_L10N: bool =

Undocumented

Value
True
USE_TZ: bool =

Undocumented

Value
True
_login_required_urls_env =

Undocumented