From 126c5f1e14a5a3d6f11e2b515476bb31b7ddf4b6 Mon Sep 17 00:00:00 2001 From: Alex Worrad-Andrews Date: Thu, 4 Jan 2024 22:29:36 +0000 Subject: [PATCH] Configure Whitenoise for serving simple static assets --- banmarchive/settings/base.py | 5 +++-- banmarchive/settings/production.py | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/banmarchive/settings/base.py b/banmarchive/settings/base.py index c0613d4..36a71ab 100644 --- a/banmarchive/settings/base.py +++ b/banmarchive/settings/base.py @@ -62,14 +62,15 @@ ] MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', - 'django.middleware.security.SecurityMiddleware', - + 'wagtail.contrib.redirects.middleware.RedirectMiddleware', 'banmarchive.middleware.canonical_host_redirect', ] diff --git a/banmarchive/settings/production.py b/banmarchive/settings/production.py index 0eed8f6..a6e22b3 100644 --- a/banmarchive/settings/production.py +++ b/banmarchive/settings/production.py @@ -2,6 +2,8 @@ from .base import * from urllib.parse import urlparse +STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" + DEBUG = False SECRET_KEY = os.getenv('SECRET_KEY') BASE_URL = re.sub(r'/$', '', os.getenv('BASE_URL', ''))