Documentation for FileField does not mention the delete behavior
|Reported by:||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Severity:||Normal||Keywords:||delete file update bug|
|Cc:||sjulean@…, cortland@…, michal.salaban@…||Triage Stage:||Accepted|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
The current documentation for FileField does not mention that django will delete the underlying file in some cases. I had to look through the code to figure out the exact behavior. It would be useful to have this information in the documentation.
Below is what I figured out.
- Files are deleted only if there are no other records referring to it.
- File is not deleted if you update the record with a new file. I see that #6157 mentions this, but this behavior is inconsistent with point 1 above.
- Files are deleted even if a transaction fails. I saw this behavior reported by #6456, but my application does not use transactions so this is more of an FYI.