{{{
Model A(models.Model)
file_field = models.FileField()
}}}
Save an instance of model A under a transaction block,
If the transaction fails i.e not committed/rollback , the uploaded file is
not deleted, even though the instance of the model is not saved
--
Ticket URL: <https://code.djangoproject.com/ticket/31201>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => wontfix
Comment:
This is long-standing behavior, I'm afraid.
[https://docs.djangoproject.com/en/3.0/ref/models/fields/#django.db.models.fields.files.FieldFile.delete
FileField docs]:
> Note that when a model is deleted, related files are not deleted. If you
need to cleanup orphaned files, you’ll need to handle it yourself (for
instance, with a custom management command that can be run manually or
scheduled to run periodically via e.g. cron).
c.f. Malcolm Tredinnick on
https://code.djangoproject.com/ticket/11663#comment:14
Just quickly trying to think about how one might tie the transaction
rollback into the file upload handling, a periodic cleanup command is
instantly more appealing. I hope that makes sense.
--
Ticket URL: <https://code.djangoproject.com/ticket/31201#comment:1>
* component: Uncategorized => File uploads/storage
--
Ticket URL: <https://code.djangoproject.com/ticket/31201#comment:2>