lehins / django-smartfields

Django Model Fields that are smart.
MIT License
98 stars 13 forks source link

Bulk delete doesn't cleanup files #9

Open 4lp opened 7 years ago

4lp commented 7 years ago

Hi! let me first just say I love this app. however, I noticed while playing with it that if I create a model with file or image fields, the automatic cleanup of the files only occurs if I delete the object from the database using the object's specific page in the admin page (http://url/admin//// - click 'delete' button) and does not occur with a batch delete from the model page (http://url/admin/// - select all then delete).

for my purposes this is okay for now as I'll be the only one using the admin site. just thought you'd want to know. thanks for your hard work!

lehins commented 7 years ago

Glad you like it. I kind of figure that would be the case with bulk operations. Cleanup is handled by models delete() function, which is not triggered in bulk deletes:

The delete() method does a bulk delete and does not call any delete() methods on your models.

4lp commented 7 years ago

thanks, I figured it was something buried within Django I didn't completely understand. If I figure out a solution for bulk delete file cleanup I'll post it.