Taken from django-cms/django-cms#5787 by @bcdickinson:
Using a simplified version of the HelloPlugin
class from the tutorial, but with text_enabled
set to True
:
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from cms.models.pluginmodel import CMSPlugin
from django.utils.translation import ugettext_lazy as _
from django.templatetags.static import static
class HelloPlugin(CMSPluginBase):
model = CMSPlugin
render_template = "hello_plugin.html"
cache = False
text_enabled = True
def icon_src(self, instance):
return static('user.svg')
plugin_pool.register_plugin(HelloPlugin)
hello_plugin.html:
When it's first added to a text plugin everything works as expected:

... however, once the containg Text plugin is saved and reopened then the content of the plugin ("Hello") is no longer a plugin block, but editable text. Additionally, the <cms-plugin>
element is now empty in the source view:
<p>Real text content</p>
<p><cms-plugin alt="Hello Plugin - 21 " id="21" render-plugin="true" title="Hello Plugin - 21"></cms-plugin></p>
<h1>Hello</h1>
<p> </p>
Saving and reopening the parent text plugin adds a new occurrence of the text every time after this, too:
<p>Real text content</p>
<p><cms-plugin alt="Hello Plugin - 21 " id="21" render-plugin="true" title="Hello Plugin - 21"></cms-plugin></p>
<h1>Hello</h1>
<p> </p>
<h1>Hello</h1>
<p> </p>