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

Have option to use django-cleanup explicitly on models

Open daviddavis opened this issue 4 years ago • 5 comments

By default, django-cleanup works by cleaning all models unless you explicitly ignore them with @cleanup.ignore. I'm wondering if django-cleanup could work in such a way that it doesn't cleanup any models unless you explicitly ask it to?

For example:

@cleanup.cleanup
class UserImage(models.Model):
    image = models.FileField()

daviddavis avatar Aug 13 '20 12:08 daviddavis

Maybe extends from some class instead?

class UserImage(cleanup.CleanUp, models.Model):
    image = models.FileField()

wlisesrivas avatar Aug 18 '20 16:08 wlisesrivas

My initial thought is that the implementation would follow the way that cleanup.ignore is implemented as a decorator.

Then add additional configuration in addition to the default django_cleanup.apps.CleanupConfig (which is what one adds to INSTALLED_APPS) so then there would be two configs:

django_cleanup.apps.CleanupConfig: current default behavior, cleans all, ignore model using @cleanup.ignore.

django_cleanup.apps.CleanupSelectedConfig: only cleans selected, select model using @cleanup.cleanup.

Not sure about the extends method, it would seem to bring in defining how it works with inheritance. Right now @cleanup.ignore does not mark subclasses as ignored.

vinnyrose avatar Aug 20 '20 19:08 vinnyrose

@vinnyrose that sounds like a fine solution.

FWIW, our project decided to use django-cleanup as it is and add @cleanup.ignore to the models we want to ignore. So we no longer need this.

Thank you for this project by the way. It's super useful.

daviddavis avatar Aug 20 '20 20:08 daviddavis

Greetings !

sorry for SPAM message.

but i would say thanks to django-cleanup developers ;X

Tnx a lot for this module :XXXXX

alimp5 avatar Mar 01 '21 06:03 alimp5

@vinnyrose That solution sounds great, and I would still love to see it implemented, if it is still in the works.

UDAR-TomH avatar Aug 30 '22 18:08 UDAR-TomH

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Mar 14 '23 01:03 github-actions[bot]