I did not understand that sender
was an optional parameter for connect
. I can do the following:
def pre_save_handler(**kwargs): instance = kwargs['instance'] if hasattr(instance, 'pre_save'): instance.pre_save() pre_save.connect(pre_save_handler)
This allows me to write using the Model pre_save
methods, and they, in turn, can call any version of the base class (if they exist).
Any better solutions?
source share