@receiver(pre_save, sender=Plan)
def plan_pre_save(sender, **kwargs):

    plan = kwargs.get('instance')
    LOG.debug("plan pre-save triggered")
    if plan.is_default:
        LOG.debug(
            "looking for other plans marked as default (they will be marked as false) with engine type %s" % plan.engine_type)
        if plan.id:
            plans = Plan.objects.filter(
                is_default=True, engine=plan.engine).exclude(id=plan.id)
        else:
            plans = Plan.objects.filter(
                is_default=True, engine=plan.engine)
        if plans:
            with transaction.commit_on_success():
                for plan in plans:
                    LOG.info(
                        "marking plan %s(%s) attr is_default to False" % (plan, plan.engine_type))
                    plan.is_default = False
                    plan.save(update_fields=['is_default'])
        else:
            LOG.debug("No plan found")
plan pre save
dataset/ETHPy150Open globocom/database-as-a-service/dbaas/physical/models.py/plan_pre_save