From aad38900870276e7624917cceea546b0e0d512b9 Mon Sep 17 00:00:00 2001 From: elisakiv Date: Thu, 18 Jan 2024 19:41:00 +0100 Subject: [PATCH 1/3] Bump django from 4.1.7 to 4.2.9 --- requirements.txt | 2 +- src/web/settings.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index ed7ed248..4cb5be2e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/src/web/settings.py b/src/web/settings.py index efd32ba7..31460c93 100644 --- a/src/web/settings.py +++ b/src/web/settings.py @@ -403,7 +403,11 @@ 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 = { + "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 From 066cce6f3e5acd75bc178f88c4097f3be5ccfd69 Mon Sep 17 00:00:00 2001 From: elisakiv Date: Thu, 25 Jan 2024 19:05:55 +0100 Subject: [PATCH 2/3] Added necessary default storage to settings --- src/web/settings.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/web/settings.py b/src/web/settings.py index 31460c93..3e65a1fe 100644 --- a/src/web/settings.py +++ b/src/web/settings.py @@ -404,8 +404,11 @@ 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 STORAGES = { - "staticfiles": { - "BACKEND": "web.static.ManifestStaticFilesStorage", + "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: From 80366e19aa6cc0f07d1b2433e6f2ec519359367a Mon Sep 17 00:00:00 2001 From: elisakiv Date: Thu, 25 Jan 2024 19:06:54 +0100 Subject: [PATCH 3/3] Fixed issue in static.py --- src/web/static.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/web/static.py b/src/web/static.py index 8a7a7e00..1cc16b3a 100644 --- a/src/web/static.py +++ b/src/web/static.py @@ -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)