Skip to content

Commit

Permalink
add support for Django 4.2 storages
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrDlouhy committed Nov 16, 2023
1 parent 77265b7 commit df37467
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions easy_thumbnails/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@

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 @@ -22,10 +37,4 @@ def __init__(self, location=None, base_url=None, *args, **kwargs):
super().__init__(location, base_url, *args, **kwargs)


class ThumbnailDefaultStorage(LazyObject):
def _setup(self):
self._wrapped = get_storage_class(
settings.THUMBNAIL_DEFAULT_STORAGE)()


thumbnail_default_storage = ThumbnailDefaultStorage()
thumbnail_default_storage = get_storage()

0 comments on commit df37467

Please sign in to comment.