def delete_child(obj, child_model, ar=None, using=None):
    """
    Delete the `child_model` instance related to `obj` without
    deleting the parent `obj` itself.
    """
    # logger.info(u"delete_child %s from %s",child_model.__name__,obj)
    using = using or router.db_for_write(obj.__class__, instance=obj)
    child = get_child(obj, child_model)
    if child is None:
        raise Exception((obj, child_model.__name__) % "%s has no child in %s")

    # msg = child.disable_delete(ar)
    ignore_models = set()
    # for m in models_by_base(obj.__class__):
    #     ignore_models.remove(child_model)
    msg = child._lino_ddh.disable_delete_on_object(
        obj, ignore_models)
    if msg:
        raise ValidationError(msg)
    # logger.debug(u"Delete child %s from %s",child_model.__name__,obj)
    if True:
        collector = ChildCollector(using=using)
        collector.collect([child])
        # raise Exception(repr(collector.data))
        # model = obj.__class__

        # remove the collected MTI parents so they are not deleted
        # (this idea didnt work: yes the parents were saved, but not
        # their related objects).

        # concrete_model = child_model._meta.concrete_model
        # for ptr in six.itervalues(concrete_model._meta.parents):
        #     if ptr:
        #         # raise Exception(repr(ptr.rel.model))
        #         del collector.data[ptr.rel.model]

    else:
        collector = ChildCollector(using=using)
        collector.collect([child], source=obj.__class__,
                          nullable=True, collect_parents=False)
    collector.delete()

    #~ setattr(obj,child_model.__name__.lower(),None)
    #~ delattr(obj,child_model.__name__.lower())

    # TODO: unchecking e.g. Company.is_courseprovider deletes the
    # child when saving the form, but the response to the PUT returns
    # still a True value because it works on the same memory instance
    # (`obj`).  User sees the effect only after clicking the refresh
    # button.  Fortunately there's no problem if the user unchecks the
    # field and saves the form a second time.
dataset/ETHPy150Open lsaffre/lino/lino/utils/mti.py/delete_child/swapped operands of `%`