I've got a model Picture with an ImageField. When deleting an instance of Picture, the file set in the ImageField is not deleted.
Picture
ImageField
Is it a bug? How can I do it?
Deletion of files associated with FileFields and ImageFields was intentionally removed in Django 1.3. See ticket #6456. Django uses transactions extensively to prevent data corruption if something goes wrong with the request. If a deletion transaction is rolled-backed, after the file has been deleted from the filesystem, then you now have a record pointing to a non-existent file. All tickets asking for automatic deletion to return have been summarily marked "Won't Fix", so this is not going to change.
FileField
For workarounds, see this previous StackOverflow question.
2.1m questions
2.1m answers
60 comments
57.0k users