Could not find config for 'static files' in settings.STORAGES
Asked Answered
B

2

7

This error occurs when running Django 4.2.The Default: django.contrib.staticfiles.storage.StaticFilesStorage has been deprecated.

Barbarism answered 6/6, 2023 at 3:39 Comment(0)
B
17

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",
    },
}`

 
Barbarism answered 6/6, 2023 at 3:39 Comment(0)
K
0

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.

Kinross answered 17/7 at 15:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.