diff --git a/dicquo/dicquo/settings.py b/dicquo/dicquo/settings.py index b04b690..d1bab03 100644 --- a/dicquo/dicquo/settings.py +++ b/dicquo/dicquo/settings.py @@ -58,6 +58,7 @@ INSTALLED_APPS: list[str] = [ MIDDLEWARE: list[str] = [ 'django.middleware.security.SecurityMiddleware', + 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', @@ -125,9 +126,15 @@ MEDIA_URL = '/media/' # Using pathlib for cleaner path management # Adjusted to serve from public/media relative to project root MEDIA_ROOT = BASE_DIR.parent / 'public/media' -STATIC_ROOT = BASE_DIR.parent / 'public/static' + +# STATIC_ROOT is where collectstatic collects files for production. +# It cannot be the same as a directory in STATICFILES_DIRS. +STATIC_ROOT = BASE_DIR.parent / 'staticfiles' STATICFILES_DIRS = [ - # Add other static dirs here if needed + BASE_DIR.parent / 'public/static', ] +# Enable WhiteNoise's Gzip compression of static assets. +if not DEBUG: + STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' diff --git a/poetry.lock b/poetry.lock index 74d941a..6d19a53 100644 --- a/poetry.lock +++ b/poetry.lock @@ -102,6 +102,28 @@ beautifulsoup4 = ">=4.10.0" lxml = ">=4.9.0" regex = ">=2022.1.18" +[[package]] +name = "gunicorn" +version = "25.1.0" +description = "WSGI HTTP Server for UNIX" +optional = false +python-versions = ">=3.10" +files = [ + {file = "gunicorn-25.1.0-py3-none-any.whl", hash = "sha256:d0b1236ccf27f72cfe14bce7caadf467186f19e865094ca84221424e839b8b8b"}, + {file = "gunicorn-25.1.0.tar.gz", hash = "sha256:1426611d959fa77e7de89f8c0f32eed6aa03ee735f98c01efba3e281b1c47616"}, +] + +[package.dependencies] +packaging = "*" + +[package.extras] +eventlet = ["eventlet (>=0.40.3)"] +gevent = ["gevent (>=24.10.1)"] +http2 = ["h2 (>=4.1.0)"] +setproctitle = ["setproctitle"] +testing = ["coverage", "eventlet (>=0.40.3)", "gevent (>=24.10.1)", "h2 (>=4.1.0)", "httpx[http2]", "pytest", "pytest-asyncio", "pytest-cov", "uvloop (>=0.19.0)"] +tornado = ["tornado (>=6.5.0)"] + [[package]] name = "lxml" version = "6.0.2" @@ -257,6 +279,17 @@ html-clean = ["lxml_html_clean"] html5 = ["html5lib"] htmlsoup = ["BeautifulSoup4"] +[[package]] +name = "packaging" +version = "26.0" +description = "Core utilities for Python packages" +optional = false +python-versions = ">=3.8" +files = [ + {file = "packaging-26.0-py3-none-any.whl", hash = "sha256:b36f1fef9334a5588b4166f8bcd26a14e521f2b55e6b9de3aaa80d3ff7a37529"}, + {file = "packaging-26.0.tar.gz", hash = "sha256:00243ae351a257117b6a241061796684b084ed1c516a08c48a3f7e147a9d80b4"}, +] + [[package]] name = "pillow" version = "12.1.1" @@ -564,7 +597,21 @@ files = [ {file = "tzdata-2025.3.tar.gz", hash = "sha256:de39c2ca5dc7b0344f2eba86f49d614019d29f060fc4ebc8a417896a620b56a7"}, ] +[[package]] +name = "whitenoise" +version = "6.11.0" +description = "Radically simplified static file serving for WSGI applications" +optional = false +python-versions = ">=3.9" +files = [ + {file = "whitenoise-6.11.0-py3-none-any.whl", hash = "sha256:b2aeb45950597236f53b5342b3121c5de69c8da0109362aee506ce88e022d258"}, + {file = "whitenoise-6.11.0.tar.gz", hash = "sha256:0f5bfce6061ae6611cd9396a8231e088722e4fc67bc13a111be74c738d99375f"}, +] + +[package.extras] +brotli = ["brotli"] + [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "52e1781b6a9c2d36cbc489df80b56a23e5459ed3247c052b6e89287bcfbfb58b" +content-hash = "e8bffeb8adca36fe7ff2ac03008ed108ef8eb37bc128ff58b0d991257e9694f6" diff --git a/pyproject.toml b/pyproject.toml index 5bf6b2e..d4aee96 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,6 +14,8 @@ pillow = "^12.1.1" pytils = "^0.4.4" etpgrf = "^0.1.4" django-environ = "^0.12.1" +whitenoise = "^6.11.0" +gunicorn = "^25.1.0" [build-system]