Skip to content

Commit

Permalink
add support for Django 4.2 storages SmileyChris#626
Browse files Browse the repository at this point in the history
  • Loading branch information
6u1ll4um3B committed Mar 22, 2024
1 parent 77265b7 commit 0c99186
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion easy_thumbnails/storage.py
Expand Up @@ -4,6 +4,20 @@

from easy_thumbnails.conf import settings

def get_storage():
# If the user has specified a custom storage backend, use it.
if getattr(settings, "THUMBNAIL_DEFAULT_STORAGE", None):
try:
storage_class = get_storage_class(settings.THUMBNAIL_DEFAULT_STORAGE)
class ThumbnailDefaultStorage(LazyObject):
def _setup(self):
self._wrapped = storage_class()
return ThumbnailDefaultStorage()
except (ImportError, TypeError):
from django.core.files.storage import storages
return storages[settings.THUMBNAIL_DEFAULT_STORAGE]
return None


@deconstructible
class ThumbnailFileSystemStorage(FileSystemStorage):
Expand All @@ -28,4 +42,4 @@ def _setup(self):
settings.THUMBNAIL_DEFAULT_STORAGE)()


thumbnail_default_storage = ThumbnailDefaultStorage()
thumbnail_default_storage = get_storage()

0 comments on commit 0c99186

Please sign in to comment.