Closed mina-gaid closed 5 years ago
Hi, The wiki is very out-of-date; A few years ago, Django changed its behaviour: it used to automatically delete associated files when a model instance was deleted. This is no longer true. I strongly suspect that we've never updated Photologue to handle this. I'm a bit busy at the moment, so it might be a few weeks before I can look into this. But if you want to send in a PR then please do! :)
Hope the issue can be fixed soon.
After thinking a bit more about this ticket: default behaviour in Django is to not delete an associated file when a model instance is deleted. I think that it's good if Photologue behaves in the default manner. If, for a particular project, it's preferable to delete files when a model instance is deleted, then it's easy enough to write a signal receiver in the project that performs this action. So I'm going to mark this as "won't fix".
@richardbarran Can't argue with that. Makes the app easier to maintain as well. Thanks.
For those, like me, who were looking for a solution to this, check out django-cleanup.
It takes less than a minute to set up and works beautifully with photologue or all media files in general.
No code needed, just pip install django-cleanup
and add it to your INSTALLED_APPS
settings (making sure to always place last, under all the other apps).
Images, including thumbnails and generated displays remain undeleted in the media folder.
As can be seen here
Photologue is not automatically deleting images from the project dire.