This error occurs when running Django 4.2.The Default: django.contrib.staticfiles.storage.StaticFilesStorage
has been deprecated.
Could not find config for 'static files' in settings.STORAGES
Asked Answered
The Default: django.contrib.staticfiles.storage.StaticFilesStorage
has been deprecated in later versions of Django.
Deprecated since version 4.2:
This setting is deprecated. Starting with Django 4.2, static files storage engine can be configured with the STORAGES setting under the staticfiles key.
FIX
STORAGES
New in Django 4.2.
Default:
STORAGES = {
"default": {
"BACKEND": "django.core.files.storage.FileSystemStorage",
},
"staticfiles": {
"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
},
}`
If you prefer, you can copy from global_settings.STORAGES
and update your options.
import copy
from email.utils import getaddresses
STORAGES = copy.deepcopy(global_settings.STORAGES)
# Example using whitenoise compress
STORAGES.update(
{
"staticfiles": {
"BACKEND": "whitenoise.storage.CompressedStaticFilesStorage",
},
}
)
With this, you will retain the default Django storages.
© 2022 - 2024 — McMap. All rights reserved.