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

Django's get_storage_class is deprecated in 4.2 (Django 5.1 compat.) #1187

Open
AngellusMortis opened this issue May 11, 2023 · 5 comments
Open

Comments

@AngellusMortis
Copy link

Got the following warning running tests in Django 4.2:

/usr/local/lib/python3.11/site-packages/django/core/files/storage/__init__.py:32 RemovedInDjango51Warning: django.core.files.storage.get_storage_class is deprecated in favor of using django.core.files.storage.storages.
@AngellusMortis AngellusMortis changed the title get_storage_class is deprecated in 4.2 Django's get_storage_class is deprecated in 4.2 May 11, 2023
@carltongibson
Copy link
Contributor

Hi @AngellusMortis thanks for the report.

The progress here would be to make a compatibility shim using the new approach on 4.2+, which we'd drop when that's the minimum supported version.

Is that something you'd like to have a go at doing?

@jvacek
Copy link
Contributor

jvacek commented May 13, 2023

This won't be deprecated until 5.1, so I don't think this should block Django 4.2 compat just yet

@carltongibson
Copy link
Contributor

carltongibson commented May 14, 2023

Yep. It's just a warning at this stage.

  File ".../compressor/storage.py", line 115, in _setup
    self._wrapped = get_storage_class(settings.COMPRESS_STORAGE)()
  File ".../django/core/files/storage/__init__.py", line 32, in get_storage_class
    warnings.warn(GET_STORAGE_CLASS_DEPRECATED_MSG, RemovedInDjango51Warning)
django.utils.deprecation.RemovedInDjango51Warning: django.core.files.storage.get_storage_class is deprecated in favor of using django.core.files.storage.storages.

@adnathanail
Copy link

Hi - I've just had a go at creating a shim in #1216, please let me know if there are any issues with it!

@carltongibson
Copy link
Contributor

#1244 was a duplicate. Copying comment from there:

We need to adjust how we reference the storages. There are a couple of PRs pointing in that direction, but we need to sit down and decide the pattern.

My current thinking is that we need to add a COMPRESS_STORAGE_ALIAS setting, and then have compressor use that if defined, or add an entry using COMPRESS_STORAGE if not, probably at the moment of populating the AppRegistry, i.e. when INSTALLED_APPS is processed.

It's on my radar to address this (if still pending) after DjangoCon Europe, so in the next few weeks.

@carltongibson carltongibson changed the title Django's get_storage_class is deprecated in 4.2 Django's get_storage_class is deprecated in 4.2 (Django 5.1 compat.) May 23, 2024
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

4 participants