Here is what is run on pre_delete of model Document. This code gets royally ignored when put in a separate file (signals.py) as suggested best practice. When put in model file, it works fine.
from django.db.models.signals import pre_delete, pre_save
from django.dispatch import receiver
from _myTools.functions import ImageProcessing
from content_image.models import Document
import os
# Image deletion when deleting entire entry
@receiver(pre_delete, sender=Document, dispatch_uid='document_delete_signal')
def entry_deletion_images_delete(sender, instance, using, **kwargs):
for key, value in instance.imageSizes.items():
name_of_image_field = str(getattr(instance, key)) # Converts to string, if not is object itself
os.remove(instance.baseDir + name_of_image_field)
setattr(instance, key, None)
So what is the problem ? Should I import something more in there ? Or should I import this file somewhere ?