django-cms子插件没有注册

时间:2015-08-29 03:49:41

标签: python django django-cms

在cms_plugins.py中我有一个父插件和子插件

from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from banner_plugin.models import BannerPluginModel, BannerItem
from banner_plugin.admin import BannerInlineAdmin, BannerLinksInlineAdmin
from django.utils.translation import ugettext as _


class CMSBannerParentPlugin(CMSPluginBase):
    model = BannerPluginModel  # model where plugin data are saved
    module = _("Banners")
    name = _("Banner Parent Plugin")  # name of the plugin in the interface
    render_template = "djangocms_banner/banner_parent_plugin.html"
    allow_chldren = True
    child_classes = ['CMSBannerChildPlugin']

    def render(self, context, instance, placeholder):
        context.update({'instance': instance})
        return context


plugin_pool.register_plugin(CMSBannerParentPlugin) 

class CMSBannerChildPlugin(CMSPluginBase):
    model = BannerItem  # model where plugin data are saved
    module = _("Banners")
    name = _("Banner Child Plugin")  # name of the plugin in the interface
    render_template = "djangocms_banner/banner_child_plugin.html"
    parent_classes = ['CMSBannerParentPlugin']
    inlines = (BannerLinksInlineAdmin,)

    def render(self, context, instance, placeholder):
        context.update({'instance': instance})
        return context

 # register the plugin
plugin_pool.register_plugin(CMSBannerChildPlugin)

当我运行项目时,只有Banner Parent Plugin出现在模块Banners中。可能是什么错误。 banner_parent_plugin.htmlbanner_child_plugin.html都存在。

在models.py中我有

class BannerPluginModel(CMSPlugin):
     // no fields here

    def __unicode__(self):
        return "Banners"


class BannerItem(CMSPlugin):
    // fields goes here

    def __unicode__(self):
        return self.heading


class BannerLinks(models.Model):
    // fields goes here
    banner_item = models.ForeignKey(to=BannerItem, related_name="links", null=True, blank=True)

1 个答案:

答案 0 :(得分:1)

查看代码以解决一个小问题:

allow_chldren = True应为allow_children = True

当您使用类时,这不是一个例外。

不确定您的代码是否还有其他问题,请尝试此操作并随时更新。

祝你好运

相关问题