Opened 17 years ago
Closed 14 years ago
#6792 closed Uncategorized (duplicate)
Documentation for FileField does not mention the delete behavior
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
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 |
Easy pickings: | no | UI/UX: | no |
Description
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.
Change History (8)
comment:1 by , 16 years ago
Keywords: | bug added |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 16 years ago
Cc: | added |
---|
comment:3 by , 16 years ago
- If file field is None, delete() will try to delete the parent folder, and a access error occured.
comment:4 by , 16 years ago
Cc: | added |
---|
Is this also the ticket representing the bug where using a ModelForm to change a FileField from one file to another causes the old file to remain on the filesystem?
comment:5 by , 16 years ago
Cc: | added |
---|
comment:6 by , 14 years ago
@pixelcort: probably not, it was #6157 (marked as wontfix)
I think there should be some kind of delete=bool or delete_on_modify=bool for image and file fields.
comment:7 by , 14 years ago
FTR, there is a pretty good summary of the issue at http://haineault.com/blog/147/
comment:8 by , 14 years ago
Resolution: | → duplicate |
---|---|
Severity: | → Normal |
Status: | new → closed |
Type: | → Uncategorized |
Files aren't deleted any more, but the documentation still needs to be improved. Since the issue is now actually the opposite one, I'll close as dupe of #15588 which is more up-to-date.