From ca527289afc841aa9079780ee251de6741f03900 Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Mon, 26 Jun 2023 22:10:29 +0800 Subject: [PATCH] Added and configured whitenoise --- .gitignore | 1 + Pipfile | 1 + Pipfile.lock | 10 +++++++++- stude/config/settings.py | 5 +++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 2fe0678..d298cb6 100644 --- a/.gitignore +++ b/.gitignore @@ -63,6 +63,7 @@ db.sqlite3-journal # Static Media Stuff stude/media/* +stude/static/* # Flask stuff: instance/ diff --git a/Pipfile b/Pipfile index 75c25e0..6e5a135 100644 --- a/Pipfile +++ b/Pipfile @@ -9,6 +9,7 @@ djangorestframework = "*" python-dotenv = "*" djoser = "*" pillow = "*" +whitenoise = "*" [dev-packages] diff --git a/Pipfile.lock b/Pipfile.lock index c5ede72..af0eb49 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "7f8c112b62413d4c6d5b8faf2ca1dd84514614956bfd75e58491781725258ba4" + "sha256": "7a186c2a779282b0072d0634e264e5e70842a4c9676dfc4d1e18e564860e87c8" }, "pipfile-spec": 6, "requires": { @@ -434,6 +434,14 @@ ], "markers": "python_version >= '3.7'", "version": "==2.0.3" + }, + "whitenoise": { + "hashes": [ + "sha256:15fe60546ac975b58e357ccaeb165a4ca2d0ab697e48450b8f0307ca368195a8", + "sha256:16468e9ad2189f09f4a8c635a9031cc9bb2cdbc8e5e53365407acf99f7ade9ec" + ], + "index": "pypi", + "version": "==6.5.0" } }, "develop": {} diff --git a/stude/config/settings.py b/stude/config/settings.py index 9ce413f..83b4876 100644 --- a/stude/config/settings.py +++ b/stude/config/settings.py @@ -67,6 +67,7 @@ INSTALLED_APPS = [ MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', + "whitenoise.middleware.WhiteNoiseMiddleware", 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', @@ -75,6 +76,10 @@ MIDDLEWARE = [ 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] +STATIC_URL = 'static/' +STATIC_ROOT = os.path.join(BASE_DIR, 'static') +STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" + ROOT_URLCONF = 'config.urls' TEMPLATES = [