我正在尝试创建一个可以组装其他插件的Django CMS自定义插件。 据我所知,Django CMS可以使用插件嵌套来实现这一点,并且我按照示例创建了一个简单的测试用例。
我的期望是,当您进入“结构”选项卡以获取包含父插件的PlaceholderField的模型中的记录时,当您添加父插件时,该模型的弹出窗口也应该有一些编辑/创建/添加子插件实例的方法。但它没有 - 我所看到的只是父插件的字段和关于孩子的NOTHING(见下面的截图)。
或者我是否完全错过了插件嵌套的观点?
models.py:
from django.db import models
from cms.models import CMSPlugin
from cms.models.fields import PlaceholderField
from djangocms_text_ckeditor.models import AbstractText
class CustomPlugin(CMSPlugin):
title = models.CharField('Title', max_length=200, null=False)
placeholder_items = PlaceholderField ('custom-content')
renderer = models.CharField('Renderer', max_length=50, null=True, blank=True,
help_text='This is just to show that a custom renderer CAN be done here!')
class ChildTextPlugin(AbstractText):
pass
cms_plugins.py:
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from django.utils.translation import ugettext as _
from .models import CustomPlugin, ChildTextPlugin
class CMSCustomPlugin(CMSPluginBase):
model = CustomPlugin
name = _('Custom Plugin')
render_template = 'custom/custom_plugin.html'
allow_children = True
def render(self, context, instance, placeholder):
context = super(CMSCustomPlugin, self).render(context, instance, placeholder)
return context
class CMSChildTextPlugin(CMSPluginBase):
model = ChildTextPlugin
name = _('Child Text Plugin')
render_template = 'custom/child_text_plugin.html'
parent_classes = ['CMSCustomPlugin',]
def render(self, context, instance, placeholder):
context = super(ChildTextPlugin, self).render(context, instance, placeholder)
return context
plugin_pool.register_plugin(CMSCustomPlugin)
plugin_pool.register_plugin(CMSChildTextPlugin)
答案 0 :(得分:0)
......答案是"它一直在工作" ---接口在我上面发布的屏幕提交之后 - 自定义插件条目将有一个" +"图标,以及孩子们被发现的地方。