#34773: settings.STATICFILES_STORAGE does not return correct value when STORAGES
are defined
-------------------------------------+-------------------------------------
               Reporter:  Petr       |          Owner:  nobody
  DlouhĂ˝                             |
                   Type:  Bug        |         Status:  new
              Component:             |        Version:  4.2
  contrib.staticfiles                |       Keywords:  storages
               Severity:  Normal     |  staticfiles
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 I transitioned to the `STORAGES` settings introduced in Django 4.2 and I
 got `OfflineGenerationError` with `django-compressor`.
 I tracked down the issue to be actually bug in `django-debug-toolbar`'s
 `StaticFilesPanel` which patches the static files storage and doesn't
 count with the new `STORAGES`. The whole issue is described here:
 https://github.com/jazzband/django-debug-toolbar/issues/1823

 The problem itself is, that `django-debug-toolbar` is using
 `settings.STATICFILES_STORAGE` to get the storage class which returns
 `'django.contrib.staticfiles.storage.StaticFilesStorage'` even if I have
 
`settings.STORAGES["staticfiles"]["BACKEND"]='whitenoise.storage.CompressedManifestStaticFilesStorage'`.
 Since Django 4.2 requires `STATICFILES_STORAGE` to be deleted from
 settings when `STORAGES` are present I don't have `STATICFILES_STORAGE`
 set to any particular value.

 Tracking down this whole issue took me whole week and was very difficult
 to tackle, because it did appear in completely different place in the
 system (missing records in the manifest files of `django-compressor`) than
 the issue actually was (`StaticFilesPanel` in `django-debug-toolbar`).

 I think this issue partially goes on behalf of Django itself. If Django
 would return `None` value or throw an exception when accessing
 `settings.STATICFILES_STORAGE` with `STORAGES` defined I would see the
 issue immediately.
 The `settings.STATICFILES_STORAGE` could also return the same value as
 `settings.STORAGES["staticfiles"]["BACKEND"]`, but I am bigger fun of
 throwing an exception, because this could lead to other kind of unexpected
 behavior.

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070189e85e5361-c1f8de34-1ae6-403c-9c08-ec39d1ff5ba7-000000%40eu-central-1.amazonses.com.

Reply via email to