Skip to content

Commit

Permalink
Add whitenoise for static assets
Browse files Browse the repository at this point in the history
  • Loading branch information
ahosgood committed Aug 13, 2024
1 parent 6f39e21 commit c45a803
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
__pycache__
.pytest_cache
db.sqlite3
/static
/node_modules
/app/static/assets
/app/static/*.css
Expand Down
3 changes: 3 additions & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down
16 changes: 15 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c45a803

Please sign in to comment.