I have the below given structure in my project
-parentDirectory
-myModule
__init__.py
models.py
handler.py
models.py
@register
class Student():
number = models.PositiveIntegerNumber(unique=True)
name = models.CharField(max_length=64)
def post_delete:
"""some code"""
def post_save:
"""some code"""
@register
class Course(SomeBaseModel):
code = models.CharField(unique=True)
teacher = models.CharField(max_length=64)
SomeBaseModel
has post_delete
and post_save
functions defined in it.
handler.py
def register(cls_object):
@receiver(post_save, sender=cls_object.__name__)
@receiver(post_delete, sender=cls_object.__name__)
def _handler(sender, **kwargs):
print 'inside _handler'
post_save.connect(_handler, sender=cls_object.__name__)
post_delete.connect(_handler, sender=cls_object.__name__)
return cls_object
The _handler
is not getting executed when I delete any of the models. What am I missing?