Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have option to use django-cleanup explicitly on models #75

Closed
daviddavis opened this issue Aug 13, 2020 · 6 comments · Fixed by #95
Closed

Have option to use django-cleanup explicitly on models #75

daviddavis opened this issue Aug 13, 2020 · 6 comments · Fixed by #95
Assignees

Comments

@daviddavis
Copy link

daviddavis commented Aug 13, 2020

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()
@wlisesrivas
Copy link

wlisesrivas commented Aug 18, 2020

Maybe extends from some class instead?

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

@vinnyrose
Copy link
Collaborator

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 vinnyrose self-assigned this Aug 20, 2020
@daviddavis
Copy link
Author

daviddavis commented Aug 20, 2020

@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.

@alimp5
Copy link

alimp5 commented Mar 1, 2021

Greetings !

sorry for SPAM message.

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

Tnx a lot for this module :XXXXX

@UDAR-TomH
Copy link

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

@github-actions
Copy link

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 github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants