Q:

django-cms remove plugin via API

In my website I am making use of the django-cms (by then 2.4.3, now using 3.0.13) API to create pages in the backgroud when, for example, a new department is created.
        from cms.api import create_page, add_plugin

        instance.page = create_page(
            title=instance.name,
            language='en',
            published=True,
            template='template.html',
        )
        placeholder_header = instance.page.placeholders.get(slot='header_img')
        add_plugin(
            placeholder=placeholder_header,
            plugin_type='SomeRandomPlugin',
            language='en',
            department=instance,
        )
        publish_page(page=instance.page, user=User.objects.filter(is_superuser__exact=True).latest('pk'))
        # [...]

This works correctly when I want to create the page. But when I want to modify it, I first need to delete the existing plugin to create it again with the new values. But the official API does not seem to allow this. Is there a way to remove or modify an existing plugin?
Thank you in advance for all your feedback.

A:

I just found the answer myself.
Given the CMSPlugin instance, the method delete_with_public() allows to delete it.

