Deleting FileField Content

29 views
Skip to first unread message

Timothy W. Cook

unread,
Oct 24, 2013, 4:32:51 AM10/24/13
to django...@googlegroups.com
When I delete an object that has a FileField I expected that the associated file would also be removed.  But alas, this doesn't happen.  At least not through the admin interface.

Is there something I am missing?

Thanks,
Tim


--
MLHIM VIP Signup: http://goo.gl/22B0U
============================================
Timothy Cook, MSc           +55 21 94711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

Russell Keith-Magee

unread,
Oct 24, 2013, 6:00:10 AM10/24/13
to Django Users
On Thu, Oct 24, 2013 at 4:32 PM, Timothy W. Cook <t...@mlhim.org> wrote:
When I delete an object that has a FileField I expected that the associated file would also be removed.  But alas, this doesn't happen.  At least not through the admin interface.

Is there something I am missing?
 
This is by design. After all, there's no guarantee that FileField references to files on disk are unique -- so if one model instance has a reference to a file, and you delete the model instance, there might still be other model instances that have references to that file.

If you want to delete files from disk on cleanup, you can do this by customising the delete() method on your model. [1]


Yours,
Russ Magee %-)

Timothy W. Cook

unread,
Oct 24, 2013, 6:20:52 AM10/24/13
to django...@googlegroups.com
Thanks Russ. 
That makes sense of course in the bigger picture.
I was living in my own little use-case.  :-)




--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJxq84861Q7jqPwMGk5ATSztRgn5txjxR3xk5WtU9upBcbYBXg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages