From 8a6638e28d90e743c06dcb43de1fb8b7b09039ed Mon Sep 17 00:00:00 2001 From: Oliver Marks Date: Tue, 28 Feb 2017 21:19:03 +0000 Subject: [PATCH] Enable whitenoise for dev environment, closer to production --- config/settings/common.py | 2 ++ config/settings/local.py | 2 ++ config/settings/production.py | 7 ++----- config/settings/stage.py | 6 ++---- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/config/settings/common.py b/config/settings/common.py index f5608d7..bed5d47 100644 --- a/config/settings/common.py +++ b/config/settings/common.py @@ -28,6 +28,7 @@ DJANGO_APPS = ( 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', + 'whitenoise.runserver_nostatic', 'django.contrib.staticfiles', 'django.contrib.humanize', 'django.contrib.admin', @@ -65,6 +66,7 @@ INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS # ------------------------------------------------------------------------------ MIDDLEWARE = ( 'django.middleware.security.SecurityMiddleware', + 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', diff --git a/config/settings/local.py b/config/settings/local.py index 735f1a1..17249d1 100644 --- a/config/settings/local.py +++ b/config/settings/local.py @@ -90,3 +90,5 @@ CAPTCHA = { 'site': '' } +WHITENOISE_AUTOREFRESH = True +WHITENOISE_USE_FINDERS = True diff --git a/config/settings/production.py b/config/settings/production.py index 60e987c..67f3b58 100644 --- a/config/settings/production.py +++ b/config/settings/production.py @@ -24,9 +24,6 @@ SECRET_KEY = env('DJANGO_SECRET_KEY') # SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') # Use Whitenoise to serve static files # See: https://whitenoise.readthedocs.io/ -WHITENOISE_MIDDLEWARE = ('whitenoise.middleware.WhiteNoiseMiddleware', ) -MIDDLEWARE = WHITENOISE_MIDDLEWARE + MIDDLEWARE - # SECURITY CONFIGURATION # ------------------------------------------------------------------------------ @@ -93,8 +90,8 @@ AWS_HEADERS = { # Static Assets # ------------------------ -STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' - +# STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' +STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage' # COMPRESSOR # ------------------------------------------------------------------------------ COMPRESS_STORAGE = 'storages.backends.s3boto.S3BotoStorage' diff --git a/config/settings/stage.py b/config/settings/stage.py index 44e8405..c50dff0 100644 --- a/config/settings/stage.py +++ b/config/settings/stage.py @@ -24,9 +24,6 @@ SECRET_KEY = env('DJANGO_SECRET_KEY') # SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') # Use Whitenoise to serve static files # See: https://whitenoise.readthedocs.io/ -WHITENOISE_MIDDLEWARE = ('whitenoise.middleware.WhiteNoiseMiddleware', ) -MIDDLEWARE = WHITENOISE_MIDDLEWARE + MIDDLEWARE - # SECURITY CONFIGURATION # ------------------------------------------------------------------------------ @@ -93,7 +90,8 @@ AWS_HEADERS = { # Static Assets # ------------------------ -STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' +# STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' +STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage' # COMPRESSOR # ------------------------------------------------------------------------------