From bd584416e92a21d2c39d5d68c59d9f9157ab3736 Mon Sep 17 00:00:00 2001 From: Oleg Lavrovsky <oleg@utou.ch> Date: Mon, 12 Nov 2018 18:54:25 +0100 Subject: [PATCH] Updated Whitenoise configuration --- publichealth/settings/base.py | 6 ++++++ publichealth/settings/dev.py | 4 +++- publichealth/wsgi.py | 7 ------- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/publichealth/settings/base.py b/publichealth/settings/base.py index 81aa2cf..90a823e 100644 --- a/publichealth/settings/base.py +++ b/publichealth/settings/base.py @@ -73,6 +73,8 @@ INSTALLED_APPS = [ MIDDLEWARE_CLASSES = [ 'django.middleware.security.SecurityMiddleware', + 'whitenoise.middleware.WhiteNoiseMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', @@ -170,6 +172,10 @@ STATICFILES_DIRS = [ os.path.join(PROJECT_DIR, 'static'), ] +# Whitenoise compression and caching support +# http://whitenoise.evans.io/en/stable/django.html +STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' + STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATIC_URL = '/static/' diff --git a/publichealth/settings/dev.py b/publichealth/settings/dev.py index 2a8d532..1e2f52d 100644 --- a/publichealth/settings/dev.py +++ b/publichealth/settings/dev.py @@ -24,7 +24,9 @@ DATABASES = { } } -INSTALLED_APPS = INSTALLED_APPS + [ +INSTALLED_APPS = [ + 'whitenoise.runserver_nostatic', +] + INSTALLED_APPS + [ 'wagtail.contrib.wagtailstyleguide', ] diff --git a/publichealth/wsgi.py b/publichealth/wsgi.py index 423e47c..6003d93 100644 --- a/publichealth/wsgi.py +++ b/publichealth/wsgi.py @@ -9,11 +9,4 @@ https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/ import os -from whitenoise.django import DjangoWhiteNoise - -from django.core.wsgi import get_wsgi_application - - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "publichealth.settings.production") - -application = DjangoWhiteNoise(get_wsgi_application())