1
Fork 0

Add whitenoise for static files

This commit is contained in:
Jake Howard 2020-04-12 15:19:26 +01:00
parent e4d652ac6b
commit 65c08dc1bb
Signed by: jake
GPG key ID: 57AFB45680EDD477
3 changed files with 11 additions and 1 deletions

1
.gitignore vendored
View file

@ -214,3 +214,4 @@ dmypy.json
# End of https://www.gitignore.io/api/node,python
env/
collected-static

View file

@ -1,2 +1,4 @@
django==3.0.5
django-debug-toolbar==2.2
whitenoise==5.0.1
brotli==1.0.7

View file

@ -30,10 +30,15 @@ ALLOWED_HOSTS = "*"
# Application definition
INSTALLED_APPS = ["django.contrib.staticfiles", "debug_toolbar"]
INSTALLED_APPS = [
"whitenoise.runserver_nostatic",
"django.contrib.staticfiles",
"debug_toolbar",
]
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
@ -72,6 +77,8 @@ USE_TZ = True
# https://docs.djangoproject.com/en/3.0/howto/static-files/
STATIC_URL = "/static/"
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
STATIC_ROOT = os.path.join(BASE_DIR, "collected-static")
INTERNAL_IPS = [