From 834e5ab07173778c52631d78e67aeb21240074ba Mon Sep 17 00:00:00 2001 From: Clemens Wolff Date: Mon, 28 Jan 2019 10:35:33 -0500 Subject: [PATCH 1/4] Update whitenoise to latest version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index e931cc8f..d31dee2b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,4 +17,4 @@ social-auth-app-django==3.1.0 social-auth-core[azuread]==3.0.0 text-unidecode==1.2 tornado==5.0.2 -whitenoise==3.3.1 +whitenoise==4.1.2 From fef4b407709a58369075e5d22e91b013acd9aa04 Mon Sep 17 00:00:00 2001 From: Clemens Wolff Date: Mon, 28 Jan 2019 10:35:43 -0500 Subject: [PATCH 2/4] Make it explicit that whitenoise is being used As per http://whitenoise.evans.io/en/stable/django.html#enable-whitenoise, the whitenoise middleware should be added just after the django-security middleware. --- app/app/settings.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/app/settings.py b/app/app/settings.py index c1286f3c..662718bc 100644 --- a/app/app/settings.py +++ b/app/app/settings.py @@ -55,6 +55,7 @@ INSTALLED_APPS = [ MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', + 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', @@ -88,6 +89,8 @@ STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'server/static'), ] +STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' + WSGI_APPLICATION = 'app.wsgi.application' AUTHENTICATION_BACKENDS = [ From 6fca7d1337c83ee19bb08fd9cda8e635ee2927c1 Mon Sep 17 00:00:00 2001 From: Clemens Wolff Date: Mon, 28 Jan 2019 10:47:15 -0500 Subject: [PATCH 3/4] Make usage of whitenoise runserver explicit --- app/app/settings.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/app/settings.py b/app/app/settings.py index 662718bc..d1252a32 100644 --- a/app/app/settings.py +++ b/app/app/settings.py @@ -40,6 +40,7 @@ if os.environ.get('DEBUG') == 'False': # Application definition INSTALLED_APPS = [ + 'whitenoise.runserver_nostatic', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', From bb36151a775968d708ac4ada1b55dc1ab0b71ca5 Mon Sep 17 00:00:00 2001 From: Clemens Wolff Date: Mon, 28 Jan 2019 10:47:46 -0500 Subject: [PATCH 4/4] Enable optional brotli compression --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index d31dee2b..f532c1c2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,4 +17,4 @@ social-auth-app-django==3.1.0 social-auth-core[azuread]==3.0.0 text-unidecode==1.2 tornado==5.0.2 -whitenoise==4.1.2 +whitenoise[brotli]==4.1.2