From ab7ba231ee09022ab11cf5c9e84ba0922408785c Mon Sep 17 00:00:00 2001 From: Sage Abdullah Date: Wed, 20 Sep 2023 16:06:08 +0100 Subject: [PATCH] Use django.core.files.storage.storages in favour of get_storage_class() --- wagtail/admin/staticfiles.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/wagtail/admin/staticfiles.py b/wagtail/admin/staticfiles.py index 51832dffce..691657d1e2 100644 --- a/wagtail/admin/staticfiles.py +++ b/wagtail/admin/staticfiles.py @@ -2,7 +2,6 @@ import hashlib from django.conf import settings from django.contrib.staticfiles.storage import HashedFilesMixin -from django.core.files.storage import get_storage_class from django.templatetags.static import static from wagtail import __version__ @@ -23,7 +22,17 @@ except AttributeError: use_version_strings = True else: # see if we're using a storage backend using hashed filenames - storage = get_storage_class(settings.STATICFILES_STORAGE) + try: + from django.conf import STATICFILES_STORAGE_ALIAS + from django.core.files.storage import storages + + storage = storages[STATICFILES_STORAGE_ALIAS].__class__ + except ImportError: + # DJANGO_VERSION < 4.2 + from django.core.files.storage import get_storage_class + + storage = get_storage_class(settings.STATICFILES_STORAGE) + use_version_strings = not issubclass(storage, HashedFilesMixin)