Skip to content

Commit 3515238

Browse files
author
Application Deployment
committed
* add whitenoise middleware to serve static files
* move more local/env-dependent settings from settings.py to settings.ini or env-vars * add an example for settings.ini
1 parent c5c2e80 commit 3515238

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[settings]
2+
DEBUG=False
3+
SECRET_KEY=django-insecure-wiq2-hvjf4#jgoq-&#rg!)hw*(wa9l9^&cgcohq8k6ihitx9f#
4+
SECRET_ENCRYPTION_KEY=x1_JDNmuikh7MQFzIQJFvmJDFbeOsacJRvvvwq3xv6a=
5+
ALLOWED_HOSTS = 127.0.0.1, localhost
6+
CSRF_TRUSTED_ORIGINS = https://mdc.domain.local
7+

masterdata_checker/checker/settings.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
OPENBIS_URL = "https://main.datastore.bam.de/"
3131

3232
# SECURITY WARNING: don't run with debug turned on in production!
33-
DEBUG = False
33+
DEBUG = environ("DEBUG", default=False)
3434

35-
ALLOWED_HOSTS = ["localhost", "127.0.0.1", "141.63.249.193", "141.63.249.2"]
35+
ALLOWED_HOSTS = environ("ALLOWED_HOSTS", default=['127.0.0.1', 'localhost'], cast=lambda v: [s.strip() for s in v.split(',')])
3636

3737
CACHES = {
3838
"default": {
@@ -55,6 +55,7 @@
5555

5656
MIDDLEWARE = [
5757
"django.middleware.security.SecurityMiddleware",
58+
"whitenoise.middleware.WhiteNoiseMiddleware",
5859
"django.contrib.sessions.middleware.SessionMiddleware",
5960
"django.middleware.common.CommonMiddleware",
6061
"django.middleware.csrf.CsrfViewMiddleware",
@@ -63,7 +64,7 @@
6364
"django.middleware.clickjacking.XFrameOptionsMiddleware",
6465
]
6566

66-
CSRF_TRUSTED_ORIGINS = ["http://141.63.249.193:8000"]
67+
CSRF_TRUSTED_ORIGINS = environ("CSRF_TRUSTED_ORIGINS", default=[], cast=lambda v: [s.strip() for s in v.split(',')])
6768

6869
ROOT_URLCONF = "checker.urls"
6970

@@ -148,6 +149,7 @@
148149

149150
STATIC_URL = "/static/"
150151
STATICFILES_DIRS = [BASE_DIR / "app/static"]
152+
STATIC_ROOT = STATICFILES_DIRS[0]
151153

152154
# Default primary key field type
153155
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ license = { file = "LICENSE" }
3030
dependencies = [
3131
"bam-masterdata>=0.4.2",
3232
"django",
33+
"whitenoise",
3334
"pybis~=1.37.1rc4",
3435
"cryptography>=45.0.2",
3536
"python-decouple",
@@ -130,4 +131,4 @@ where = ["."]
130131
namespaces = false
131132

132133
[tool.setuptools_scm]
133-
write_to = "masterdata_checker/_version.py"
134+
write_to = "masterdata_checker/_version.py"

0 commit comments

Comments
 (0)