Django-cms CMS插件在内联创建内联后不会出现在编辑模式下

时间:2018-05-03 13:54:28

标签: django django-cms

我有一个小部件'快速链接'我想在我的页脚中添加(在静态占位符中)

我可以添加小部件和所有内联。创建后,我可以在已发布模式下看到内联,但在编辑模式下窗口小部件为空。你能帮帮我吗?

Models.py

class LienFooterPlugin(CMSPlugin):
    langue = models.CharField(max_length=128)

def copy_relations(self, oldinstance):
    self.lien_footer = oldinstance.lien_footer.all()

    for lien_footer in oldinstance.lien_footer.all():
        lien_footer.pk = None
        lien_footer.plugin = self
        lien_footer.save()

class LienFooter(models.Model):
    class Meta:
        ordering = ["ordre"]

    lienfooter  = models.ForeignKey(LienFooterPlugin, related_name="lien_footer")
    titre   = models.CharField(max_length=150, blank=True, null=True)
    adresse     = models.CharField(max_length=150, blank=True, null=True)
    ordre       = models.PositiveIntegerField(default=1)

admin.py

class LienFooterInline(admin.StackedInline):
    model = LienFooter

cms_plugins.py

class LienFooterAppPlugin(CMSPluginBase):
    model = LienFooterPlugin
    name = u'Liens rapides'
    render_template = "widget/_liens_footer.html"
    inlines = (LienFooterInline,)


    def __init__(self, model=None, admin_site=None):
        super(LienFooterAppPlugin, self).__init__(model=model,
                                                  admin_site=admin_site)
        for inline in self.inlines:
            inline.placeholder = self.placeholder
            inline.page = self.page


    def render(self, context, instance, placeholder):
        context = super(LienFooterAppPlugin, self).render(context, instance, placeholder)
        items = instance.lien_footer.all()
        context.update({
            'model':instance,
            'placeholder': placeholder,
            'items': items,

        })
        return context

plugin_pool.register_plugin(LienFooterAppPlugin)

非常感谢你的帮助!

0 个答案:

没有答案