Skip to content

Replace DEFAULT_FILE_STORAGE with STORAGES  #369

@awais786

Description

@awais786

Django 4.2 introduced the STORAGES setting, a modern and more flexible mechanism for configuring multiple storage backends. As of Django 5.2, DEFAULT_FILE_STORAGE and STORAGES are mutually exclusive, and using both simultaneously will raise an ImproperlyConfigured error.

Goal
Remove the legacy DEFAULT_FILE_STORAGE setting from openedx and migrate to the STORAGES dictionary-based configuration.

Current Approach
For compatibility with Django 5.2, we're currently loading storage classes using:
from django.utils.module_loading import import_string

But if future we should use the storages.

sample setting

STORAGES = {
    "default": {
        "BACKEND": "django.core.files.storage.FileSystemStorage",
    },
    "profile_images": {
        "BACKEND": "openedx.core.storage.OverwriteStorage",
        "OPTIONS": {
            "location": os.path.join(MEDIA_ROOT, "profile-images/"),
            "base_url": os.path.join(MEDIA_URL, "profile-images/"),
        },
    },
    "course_metadata_export": {
        "BACKEND": "openedx.core.storage.OverwriteStorage",
        "OPTIONS": {
            "location": os.path.join(MEDIA_ROOT, "courses-export/"),
            "base_url": os.path.join(MEDIA_URL, "courses-export/"),
        },
    },
}

Django useful PR django/django#15610

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions