Please have a look at following code.
pre_save and post_delete signal handlers are used here to
automatically delete unused files.
Signal handlers are generic in nature as the use isinstance(field,
models.FileField) to identify file fields.
Source -
https://github.com/un1t/django-cleanup/blob/m
You could remember the old path by saving it as a variable in your
model's __init__ function.
Something like this:
self._old_file_path = self.file_path
Then in your save():
#only if there was a non-blank path to begin with, and it changed
if self._old_file_path and ( self._old_file_
Hi,
As it seems Django doesn't handle the update and delete of files from a
FileField by itself leaving you them pretty hard to use by default.
I tried search around but couldn't find a proper answer as to the correct
way of handling this.
I'm looking for the case where when the file is update
3 matches
Mail list logo