Enrique Uzcategui
Enrique Uzcategui

Reputation: 102

When are post_save() signals executed in Django?

I want to override a save() method that is connected to a post_save() signal, if I do, when will the signal be executed? When the method ended or when I call super? Here I explain my question with code:

def __init__(self, *args, **kwargs):
    super(Model, self).__init__(*args, **kwargs)
    self.__original_field = self.field

def save(self, force_insert=False, force_update=False, *args, **kwargs):

    if self.__original_field < self.field:
        # Do something
    
    # The signal will be executed after this line?
    super(Model, self).save(force_insert, force_update, *args, **kwargs)

    # Or after this line?        
    self.__original_field = self.field

Upvotes: 1

Views: 101

Answers (1)

Enrique Uzcategui
Enrique Uzcategui

Reputation: 102

I used the debugger to solve this doubt and in turns out the signal executes after the super() and then the rest of the save() method is executed.

Upvotes: 1

Related Questions