richardbarran / django-photologue

A customizable plug-in photo gallery management application for the Django web framework.
BSD 3-Clause "New" or "Revised" License
674 stars 239 forks source link

Deleted images remain in the media folder #184

Closed mina-gaid closed 5 years ago

mina-gaid commented 6 years ago

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.

richardbarran commented 6 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! :)

mina-gaid commented 6 years ago

Hope the issue can be fixed soon.

richardbarran commented 5 years ago

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

mina-gaid commented 5 years ago

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