Skip to content

Commit 6500559

Browse files
committed
Added WhiteNoise to serve static files
1 parent b748b42 commit 6500559

File tree

4 files changed

+93
-47
lines changed

4 files changed

+93
-47
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test: ## Ensure we can build and run a new project
2222
cd todo_project_name && make validate_terraform
2323

2424
test-static: ## Confirm nginx is serving static files
25-
curl -o /dev/null --fail --silent http://localhost:8080/static/admin/css/login.css
25+
curl -o /dev/null --fail --silent --compressed http://localhost:8080/static/admin/css/login.css
2626

2727
down: ## Shutdown the containers
2828
cd todo_project_name && make local.down

{{ cookiecutter.project_slug }}/Pipfile

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ django-model-utils = "~=3.1"
1212
gevent = "~=1.3"
1313
gunicorn = "~=19.9"
1414
psycopg2-binary = "~=2.7"
15+
whitenoise = {extras = ["brotli"],version = "~=4.1"}
1516

1617
[dev-packages]
1718
coverage = "~=4.5"

{{ cookiecutter.project_slug }}/Pipfile.lock

+87-46
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

{{ cookiecutter.project_slug }}/{{ cookiecutter.project_slug }}/settings.py

+4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
MIDDLEWARE = [
4242
'django.middleware.security.SecurityMiddleware',
43+
'whitenoise.middleware.WhiteNoiseMiddleware',
4344
'django.contrib.sessions.middleware.SessionMiddleware',
4445
'django.middleware.common.CommonMiddleware',
4546
'django.middleware.csrf.CsrfViewMiddleware',
@@ -131,6 +132,9 @@
131132
str(project_root.path('static')),
132133
]
133134

135+
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
136+
137+
134138
SITE_ID = 1
135139

136140
CACHES = {

0 commit comments

Comments
 (0)