Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#34273 closed Uncategorized (invalid)

settings.DEFAULT_FILE_STORAGE is not the same as settings.STORAGES["default"]

Reported by: אורי Owned by: nobody
Component: File uploads/storage Version: 4.2
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi,

I ran tests with Django 4.2 alpha and sorl-thumbnail==12.9.0. The tests pass but there is a deprecation warning because sorl-thumbnail uses THUMBNAIL_STORAGE = settings.DEFAULT_FILE_STORAGE. I tried to change the line in sorl-thumbnail to THUMBNAIL_STORAGE = settings.STORAGES["default"], and then many tests fail with error messages such as "You can't use this format for your profile picture. Only JPEG or PNG formats are accepted.". My conclusion is that settings.DEFAULT_FILE_STORAGE is not the same as settings.STORAGES["default"] in Django 4.2 alpha, and it looks like a bug. Or is it a feature?

Change History (3)

in reply to:  description ; comment:1 by Mariusz Felisiak, 2 years ago

Component: UncategorizedFile uploads/storage
Resolution: invalid
Status: newclosed

I tried to change the line in sorl-thumbnail to THUMBNAIL_STORAGE = settings.STORAGES["default"], and then many tests fail ...

STORAGES["default"] is a dictionary not a class name so you should use THUMBNAIL_STORAGE = settings.STORAGES["default"]["BACKEND"] instead, see docs.

in reply to:  1 ; comment:2 by אורי, 2 years ago

Replying to Mariusz Felisiak:

I tried to change the line in sorl-thumbnail to THUMBNAIL_STORAGE = settings.STORAGES["default"], and then many tests fail ...

STORAGES["default"] is a dictionary not a class name so you should use THUMBNAIL_STORAGE = settings.STORAGES["default"]["BACKEND"] instead, see docs.

It is written on https://docs.djangoproject.com/en/dev/releases/4.2/ :
The DEFAULT_FILE_STORAGE setting is deprecated in favor of STORAGES["default"].
You should write there how to convert from settings.DEFAULT_FILE_STORAGE to settings.STORAGES["default"]["BACKEND"]

in reply to:  2 comment:3 by Mariusz Felisiak, 2 years ago

Replying to אורי:

It is written on https://docs.djangoproject.com/en/dev/releases/4.2/ :
The DEFAULT_FILE_STORAGE setting is deprecated in favor of STORAGES["default"].
You should write there how to convert from settings.DEFAULT_FILE_STORAGE to settings.STORAGES["default"]["BACKEND"]

It's deprecated in favor of STORAGES["default"] as it's more flexible and gives more options. I don't see anything incorrect in this sentence. It's not written as "... use STORAGES["default"] instead".

Note: See TracTickets for help on using tickets.
Back to Top