Skip to content

apps

PruneMediaConfig

Bases: AppConfig

App config for django-prune-media.

check_for_media

check_for_media(app_configs, **kwargs)

Run checks to ensure that MEDIA_ROOT exists and that the configured storage backend has implemented listdir.

Source code in src/prune_media/apps.py
@register()
def check_for_media(app_configs, **kwargs):  # noqa: ARG001
    """Run checks to ensure that MEDIA_ROOT exists and that the
    configured storage backend has implemented listdir."""
    errors = []
    try:
        dirs, files = default_storage.listdir(".")
    except FileNotFoundError as fnf:
        msg = "Your media root does not exist!"
        errors.append(Error(msg, hint=str(fnf)))
    except NotImplementedError as nie:
        msg = "Your storage backend does not support listdir!"
        errors.append(Error(msg, hint=str(nie)))
    return errors