django-cleanup icon indicating copy to clipboard operation
django-cleanup copied to clipboard

Select or ignore specific model fields

Open stevelacey opened this issue 1 month ago • 1 comments

It would be helpful if django-cleanup allowed ignoring or selecting specific fields in a model.

In my project some models have fields that can't be cleaned because they have non-uniques, yet other fields would work fine.

Supporting a include/exclude list via decorators would be consistent with what already exists, but maybe a setting would be better, that'd be similar to how cacheops is configured, and I like the idea of keeping it all inside settings.py:

CLEANUP = {
    # "core.achievement": {"frame", "image", "obscure_image"},
    "core.achievementupload": {"achievement_csv"},
    "core.bitstreamversion": {"asset_file"},
    "core.cerberusversion": {"asset_file"},
    "core.feedpost": {"image"},
    # "core.machine": {"backglass_art", "logo", "template_file"},
    "core.recording": {"file"},
    "core.scoredetectorversion": {"asset_file"},
    "core.scoreimage": {"image"},
    # "core.session": {"log_file"},
    "core.slideshowimage": {"image"},
    # "core.spike2firmwareversion": {"asset_file"},
    "core.userprofile": {"profile_picture"},
}

Not really sure how you might want this to play out with the select/ignore modes, changing mode via switching AppConfig is not something I've come across in a Django package before, a setting like this seems more common 🤔

stevelacey avatar Jan 21 '25 08:01 stevelacey