Sunday, February 27, 2011

Re: ImageField not deleted while changing

Borislav is right, although it seems to me that overriding the model's save method would be more appropriate in Your case.

On the other hand, You really should think twice before doing so. There's actually a good reason for django orm not to delete the actual file after the corresponding FileField had been changed or deleted. Your models' edition/deletion is usually handled in db transactions that are rolled back when something goes wrong and unfortunately there's no way to undo a file's deletion...

Perhaps it's better to periodically run a script that deletes orphaned files.

2011/2/27 Borislav Petrović <chubzor@gmail.com>
As far as I know, you should implement the file deletion by yourself. You should code it on the Models delete function. preserving the default behaviour.
here is a link to some read: http://docs.djangoproject.com/en/dev/topics/db/models/#overriding-model-methods

How you do the file deletion is just pure python code further on.



On Sat, Feb 26, 2011 at 10:12 PM, galago <progreo@gmail.com> wrote:
d. Is it my fault or Django is designed not to delete it (if so, how to delete old fil

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment