def post_save_callback(self, sender, **kwargs): instance = kwargs['instance'] created = kwargs['created'] if not created: key = self._get_key_for_instance(instance) before = self.cache.pop(key, None) if before: after = serialize_instance(instance) diff = self._compare_dicts(before, after) if diff: model_changed.send(sender, instance=instance, raw=kwargs.get('raw'), using=kwargs.get('using'), changes=diff) else: model_added.send(sender, instance=instance, raw=kwargs.get('raw'), using=kwargs.get('using'))
def on_model_added(sender, **kwargs): record_trail('add', kwargs.get('instance', None), serialize_instance(kwargs.get('instance')))
def pre_save_callback(self, sender, **kwargs): instance = kwargs['instance'] value = serialize_instance(instance, before=True) if value: key = self._get_key_for_instance(instance) self.cache[key] = value