Opened 17 years ago

Closed 14 years ago

#6792 closed Uncategorized (duplicate)

Documentation for FileField does not mention the delete behavior

Reported by: thebitguru <farhan@…> 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.

  1. Files are deleted only if there are no other records referring to it.
  2. 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.
  3. 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 edgarsj, 17 years ago

Keywords: bug added
Triage Stage: UnreviewedAccepted

comment:2 by sjulean, 16 years ago

Cc: sjulean@… added

comment:3 by towjzhou@…, 16 years ago

  1. If file field is None, delete() will try to delete the parent folder, and a access error occured.

comment:4 by pixelcort, 16 years ago

Cc: cortland@… 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 Michał Sałaban, 16 years ago

Cc: michal.salaban@… added

comment:6 by anonymous, 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 Jannis Leidel, 14 years ago

FTR, there is a pretty good summary of the issue at http://haineault.com/blog/147/

comment:8 by Julien Phalip, 14 years ago

Resolution: duplicate
Severity: Normal
Status: newclosed
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.

Note: See TracTickets for help on using tickets.
Back to Top