Is there a way to cancel a deletion of record using django pre_delete signal?
example:
def on_delete(sender,**kwargs):
if not <some condition>:
#cancel the deletion
# else continue with the deletion
pre_delete.connect(on_delete,sender=MyModel)
and another question is there a way to say to a model "that before changing a file delete first the original file" because right now this is what I do(see code below) and I'm not sure if this is the best way to do it.
def on_save(sender,**kwargs):
obj = kwargs['instance']
try:
id = obj.pk
# find the file
original_file = sender.objects.get(pk=id)
# delete the original file before uploading a new file
original_file.file.delete()
except ....
pre_save.connect(on_save,sender=ModelWithFileUpload)
(in django 1.2 they automatically delete the file on change or on delete but in django 1.3 they removed this feature)
Thanks in advance