#2983: ImageField not deleing previously attached file when updated
-------------------------------------------+--------------------------------
          Reporter:  Shimon                |         Owner:  tbecker   
            Status:  closed                |     Milestone:            
         Component:  File uploads/storage  |       Version:  SVN       
        Resolution:  wontfix               |      Keywords:  fs-rf-docs
             Stage:  Accepted              |     Has_patch:  1         
        Needs_docs:  1                     |   Needs_tests:  1         
Needs_better_patch:  0                     |  
-------------------------------------------+--------------------------------
Changes (by SmileyChris):

  * needs_better_patch:  1 => 0
  * needs_docs:  0 => 1
  * needs_tests:  0 => 1
  * milestone:  1.1 =>

Comment:

 While I'm not going to re-open the ticket just yet, but I'm pretty sure
 that this isn't quite as easy as using a custom storage backend for the
 field.

 A common case is that you have a `ModelForm` (bound to an existing
 instance) for which you use to upload a new file. The form is saved in
 your view which overwrites the linked `FieldFile` with a new one (which
 will be based on the data from the `UploadedFile`). Now there is no
 reference to the old file, so even custom storage can't touch it (unless
 you use an upload_to callable which names it the same and your custom
 storage is changed to [dangerously] blindly overwrite files with the same
 name).

 Anyway, I've attached a patch which works well for me in limited testing.
 It'd need tests and docs of course.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/2983#comment:24>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to