code: def pre_save_config(sender, instance, *args, **kwargs):
      
      logger.debug("Received pre_save from {}".format(instance))
      if not instance.pk:
          # new model being created
          return
      try:
          old_instance = AutogroupsConfig.objects.get(pk=instance.pk)
  
          # Check if enable was toggled, delete groups?
          if old_instance.alliance_groups is True and instance.alliance_groups is False:
              instance.delete_alliance_managed_groups()
  
          if old_instance.corp_groups is True and instance.corp_groups is False:
              instance.delete_corp_managed_groups()
      except AutogroupsConfig.DoesNotExist:
          pass
docs: Checks if enable was toggled on group config and
      deletes groups if necessary.