0
他のプラグインをアセンブルできるDjango CMSカスタムプラグインを作成しようとしています。 私が知る限り、Django CMSはPluginのネストを使用してこれを行うことができます。サンプルを使って簡単なテストケースを作成しました。Django CMSプラグインのネスト---構造体インタフェースに子が表示されない
親のプラグインを含むPlaceholderFieldを持つモデルのレコードの「構造」タブに入ると、親のプラグインを追加するときに、そのモデルのポップアップにも子プラグインのインスタンスを編集/作成/追加するいくつかの方法。しかし、そうではありません---私はすべて、親プラグインのフィールドと子供に関する何もないことを見ています(下記のスクリーンショットを参照)。
また、プラグインのネスティングのポイントが完全に不足していますか?
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)