Skip to content

Commit

Permalink
Merge pull request #704 from MAKENTNU/django-4.2.0
Browse files Browse the repository at this point in the history
Bump django from 4.1.7 to 4.2.9
  • Loading branch information
elisakiv authored Feb 8, 2024
2 parents 829bd56 + 80366e1 commit 894fc01
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Django-related packages
Django==4.1.7
Django==4.2.9
django-hosts==5.2
django-ckeditor==6.7.0
django-cleanup==8.0.0
Expand Down
9 changes: 8 additions & 1 deletion src/web/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,14 @@ def generate_all_hosts(subdomains):

# This is based on Django's ManifestStaticFilesStorage, which appends every static file's MD5 hash to its filename,
# which avoids waiting for browsers' cache to update if a file's contents change
STATICFILES_STORAGE = 'web.static.ManifestStaticFilesStorage'
STORAGES = {
"default": {
"BACKEND": "django.core.files.storage.FileSystemStorage",
},
'staticfiles': {
'BACKEND': 'web.static.ManifestStaticFilesStorage',
},
}
# Ignores adding a hash to the files whose paths match these glob patterns:
# NOTE: Ignored files should be named so that it's obvious that they should be renamed when their contents update,
# to avoid being "stuck" in browsers' cache - which is what `ManifestStaticFilesStorage` would have prevented
Expand Down
15 changes: 8 additions & 7 deletions src/web/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ def get_full_static_url(url: str):
return f"{settings.STATIC_URL}{url}"

def file_hash(self, name, content=None):
normalized_file_path = Path(name).as_posix()
# Don't hash the filename if the path matches any of the patterns in the `MANIFEST_STATICFILES_IGNORE_PATTERNS` setting
if any(
fnmatchcase(normalized_file_path, pattern)
for pattern in settings.MANIFEST_STATICFILES_IGNORE_PATTERNS
):
return None
if name:
normalized_file_path = Path(name).as_posix()
# Don't hash the filename if the path matches any of the patterns in the `MANIFEST_STATICFILES_IGNORE_PATTERNS` setting
if any(
fnmatchcase(normalized_file_path, pattern)
for pattern in settings.MANIFEST_STATICFILES_IGNORE_PATTERNS
):
return None

return super().file_hash(name, content)

Expand Down

0 comments on commit 894fc01

Please sign in to comment.