Breaks with Django 5.1 | ImportError: 'get_storage_class' from 'django.core.files.storage'
With the new Django 5.1 version the latest version breaks:
app-1 | File "/app/apps/core/fields.py", line 20, in <module>
app-1 | from easy_thumbnails.files import get_thumbnailer
app-1 | File "/usr/local/lib/python3.11/site-packages/easy_thumbnails/files.py", line 13, in <module>
app-1 | from easy_thumbnails import engine, exceptions, models, utils, signals, storage
app-1 | File "/usr/local/lib/python3.11/site-packages/easy_thumbnails/storage.py", line 43, in <module>
app-1 | thumbnail_default_storage = get_storage()
app-1 | ^^^^^^^^^^^^^
app-1 | File "/usr/local/lib/python3.11/site-packages/easy_thumbnails/storage.py", line 18, in get_storage
app-1 | from django.core.files.storage import get_storage_class
app-1 | ImportError: cannot import name 'get_storage_class' from 'django.core.files.storage' (/usr/local/lib/python3.11/site-packages/django/core/files/storage/__init__.py)
To prevent this you can set THUMBNAIL_DEFAULT_STORAGE_ALIAS in settings (THUMBNAIL_DEFAULT_STORAGE_ALIAS = 'default' for example) as workaround
Workaround doesn't work for me. Still hitting a
thumbnail_default_storage = get_storage()
File "....../venv/lib/python3.10/site-packages/easy_thumbnails/storage.py", line 24, in get_storage
from django.core.files.storage import get_storage_class
ImportError: cannot import name 'get_storage_class' from 'django.core.files.storage' (......../venv/lib/python3.10/site-packages/django/core/files/storage/__init__.py)
I checked storage.py, and I seem to be hitting the InvalidStorageError in get_storage(). The storages from from django.core.files.storage import storages prints as a django.core.files.storage.handler.StorageHandler object. storages._storages is an empty dict. I wasn't able to investigate handler.py, which contains StorageHandler, because any print statements and other edits anywhere in the code seem to not update. I do know that I hit the Could not find config for '{alias}' in settings.STORAGES InvalidStorage Error. Don't care to investigate further, I'll just not use this lib.
To prevent this you can set
THUMBNAIL_DEFAULT_STORAGE_ALIASin settings (THUMBNAIL_DEFAULT_STORAGE_ALIAS= 'default' for example) as workaround
Adding THUMBNAIL_DEFAULT_STORAGE_ALIAS = 'default'` works for me. Thanks.
To prevent this you can set
THUMBNAIL_DEFAULT_STORAGE_ALIASin settings (THUMBNAIL_DEFAULT_STORAGE_ALIAS= 'default' for example) as workaroundAdding
THUMBNAIL_DEFAULT_STORAGE_ALIAS= 'default'` works for me. Thanks.
Thank you @Miketsukami and @elielmartinsbr. It also works for me. :)