def listen_to_related_object_post_delete(sender, instance, **kwargs):
    if hasattr(instance, 'get_agenda_title'):
        content_type = ContentType.objects.get_for_model(instance)
        try:
            Item.objects.get(object_id=instance.pk, content_type=content_type).delete()
        except Item.DoesNotExist:
            # Item does not exist so we do not have to delete it.
            pass
Receiver function to delete agenda items. It is connected to the signal
dataset/ETHPy150Open OpenSlides/OpenSlides/openslides/agenda/signals.py/listen_to_related_object_post_delete