I want to get the class of the sender in the code below using sender.__class__
. This works until I have a model that inherits from a base class.
For example sender is class Profile but sender.__class__
gives the base bass Profile inherits from MPTTModelBase (which is abstract = True
). Same thing with .Meta
etc.
@receiver(post_save)
def send_func(sender, instance, created, **kwargs):
print(sender) #<class 'demo.apps.t.models.Profile'>
print(sender.__class__) # <class 'mptt.models.MPTTModelBase'>
How do I get the class ignoring inherited models (if it has one)?