I am working with signals in Django, specifically with the pre_delete
signal, code:
signals.py
file:
def delete_unnecessary_image(sender, instance, using):
print('holaaaa')
instance.image.delete(save = False)
apps.py
file (here I register the receivers in the ready()
method):
def ready(self):
from .signals import delete_unnecessary_image
from .models import Course
pre_delete.connect(delete_unnecessary_image, sender = Course)
My INSTALLED_APPS
and configuration in my settings.py
:
DJANGO_APPS = [
....
]
MY_APPS = [
'core',
'courses',
'instructor'
]
INSTALLED_APPS = DJANGO_APPS + MY_APPS
The problem is that it doesn't work, it doesn't eliminate the image of the Course
model, and I don't know why. Any solution?