@receiver(pre_delete, sender=Instance)
def instance_pre_delete(sender, **kwargs):

    from backup.models import Snapshot
    import datetime

    instance = kwargs.get('instance')

    LOG.debug("instance %s pre-delete" % (instance))

    snapshots = Snapshot.objects.filter(
        instance=instance, purge_at__isnull=True)
    for snapshot in snapshots:
        LOG.debug("Setting snapshopt %s purge_at time" % (snapshot))
        snapshot.purge_at = datetime.datetime.now()
        snapshot.save()

    LOG.debug("instance pre-delete triggered")
instance pre delete
dataset/ETHPy150Open globocom/database-as-a-service/dbaas/physical/models.py/instance_pre_delete