[Django] #34273: settings.DEFAULT_FILE_STORAGE is not the same as settings.STORAGES["default"]

10 views
Skip to first unread message

Django

unread,
Jan 18, 2023, 11:35:54 PM1/18/23
to django-...@googlegroups.com
#34273: settings.DEFAULT_FILE_STORAGE is not the same as
settings.STORAGES["default"]
-----------------------------------------+------------------------
Reporter: אורי | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 4.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
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?

--
Ticket URL: <https://code.djangoproject.com/ticket/34273>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 19, 2023, 12:20:55 AM1/19/23
to django-...@googlegroups.com
#34273: settings.DEFAULT_FILE_STORAGE is not the same as
settings.STORAGES["default"]
-------------------------------------+-------------------------------------
Reporter: אורי | Owner: nobody
Type: Uncategorized | Status: closed
Component: File | Version: 4.2
uploads/storage |
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid
* component: Uncategorized => File uploads/storage


Comment:

> 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
[https://docs.djangoproject.com/en/4.2/ref/settings/#storages docs].

--
Ticket URL: <https://code.djangoproject.com/ticket/34273#comment:1>

Django

unread,
Jan 19, 2023, 12:53:07 AM1/19/23
to django-...@googlegroups.com
#34273: settings.DEFAULT_FILE_STORAGE is not the same as
settings.STORAGES["default"]
-------------------------------------+-------------------------------------
Reporter: אורי | Owner: nobody
Type: Uncategorized | Status: closed
Component: File | Version: 4.2
uploads/storage |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by אורי):

Replying to [comment:1 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
[https://docs.djangoproject.com/en/4.2/ref/settings/#storages 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"]`

--
Ticket URL: <https://code.djangoproject.com/ticket/34273#comment:2>

Django

unread,
Jan 19, 2023, 1:04:52 AM1/19/23
to django-...@googlegroups.com
#34273: settings.DEFAULT_FILE_STORAGE is not the same as
settings.STORAGES["default"]
-------------------------------------+-------------------------------------
Reporter: אורי | Owner: nobody
Type: Uncategorized | Status: closed
Component: File | Version: 4.2
uploads/storage |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

Replying to [comment:2 אורי]:


> 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"''.

--
Ticket URL: <https://code.djangoproject.com/ticket/34273#comment:3>

Reply all
Reply to author
Forward
0 new messages