Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaks with Django 5.1 | ImportError: 'get_storage_class' from 'django.core.files.storage' #641

Open
blu3f1r3 opened this issue Aug 15, 2024 · 4 comments

Comments

@blu3f1r3
Copy link

blu3f1r3 commented Aug 15, 2024

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)
@Miketsukami
Copy link

To prevent this you can set THUMBNAIL_DEFAULT_STORAGE_ALIAS in settings (THUMBNAIL_DEFAULT_STORAGE_ALIAS = 'default' for example) as workaround

@wade-cheng
Copy link

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.

@elielmartinsbr
Copy link

To prevent this you can set THUMBNAIL_DEFAULT_STORAGE_ALIAS in settings (THUMBNAIL_DEFAULT_STORAGE_ALIAS = 'default' for example) as workaround

Adding THUMBNAIL_DEFAULT_STORAGE_ALIAS = 'default'` works for me. Thanks.

@Eraldo
Copy link

Eraldo commented Sep 10, 2024

To prevent this you can set THUMBNAIL_DEFAULT_STORAGE_ALIAS in settings (THUMBNAIL_DEFAULT_STORAGE_ALIAS = 'default' for example) as workaround

Adding THUMBNAIL_DEFAULT_STORAGE_ALIAS = 'default'` works for me. Thanks.

Thank you @Miketsukami and @elielmartinsbr.
It also works for me. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants