diff --git a/.gitignore b/.gitignore index f9ee3f0..0333523 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ __pycache__ .pytest_cache db.sqlite3 +/static /node_modules /app/static/assets /app/static/*.css diff --git a/config/settings/base.py b/config/settings/base.py index ee84ef0..8a61890 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -23,6 +23,7 @@ MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", + "whitenoise.middleware.WhiteNoiseMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", @@ -113,6 +114,8 @@ STATIC_URL = "static/" STATIC_ROOT = os.path.join(BASE_DIR, "static") STATICFILES_DIRS = [os.path.join(BASE_DIR, "app/static")] +STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" + # Default primary key field type # https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field diff --git a/poetry.lock b/poetry.lock index 1105405..a25e8ea 100644 --- a/poetry.lock +++ b/poetry.lock @@ -578,7 +578,21 @@ MarkupSafe = ">=2.1.1" [package.extras] watchdog = ["watchdog (>=2.3)"] +[[package]] +name = "whitenoise" +version = "6.7.0" +description = "Radically simplified static file serving for WSGI applications" +optional = false +python-versions = ">=3.8" +files = [ + {file = "whitenoise-6.7.0-py3-none-any.whl", hash = "sha256:a1ae85e01fdc9815d12fa33f17765bc132ed2c54fa76daf9e39e879dd93566f6"}, + {file = "whitenoise-6.7.0.tar.gz", hash = "sha256:58c7a6cd811e275a6c91af22e96e87da0b1109e9a53bb7464116ef4c963bf636"}, +] + +[package.extras] +brotli = ["brotli"] + [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "fea5776619c5730000854a6107f3ccfa019e1545b2727acc35da85a3b7b5da47" +content-hash = "049c3db58c343a320ccc8972bdc159225cf064c0bfda4839143363de442bb7f5" diff --git a/pyproject.toml b/pyproject.toml index d5c80bf..9aa7c4b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,6 +13,7 @@ tna-frontend-jinja = "0.1.33" django = "^5.0.7" psycopg2-binary = "^2.9.9" django-csp = "^3.8" +whitenoise = "^6.7.0" [tool.poetry.group.dev] optional = true