[Answered ]-Django Contenttypes and decorator

2๐Ÿ‘

โœ…

If i understand you right you want to count each instantiation of every object. I would do it by using a post_init signal โ€” if you do not mind that it is not a decorator.

Here is a code, I wrote โ€“ using post_save instead of post_init:

def thumb_init(sender, **kwargs):
    kwargs['instance'].process()
    kwargs['instance'].make_thumbnail()

post_init.connect(thumb_init, sender=Thumbnail) 
post_init.connect(thumb_init, sender=<otherModel here>)  
๐Ÿ‘คvikingosegundo

Leave a comment