django-cleanup
django-cleanup copied to clipboard
Have option to use django-cleanup explicitly on models
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()
Maybe extends from some class instead?
class UserImage(cleanup.CleanUp, models.Model):
image = models.FileField()
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 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.
Greetings !
sorry for SPAM message.
but i would say thanks to django-cleanup developers ;X
Tnx a lot for this module :XXXXX
@vinnyrose That solution sounds great, and I would still love to see it implemented, if it is still in the works.
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.