Django-cms | Django范本(/的主要错误)| DuplicatePlaceholderWarning

时间:2018-07-13 07:38:15

标签: django django-templates django-cms

这是我每次添加子ImageUpload插件并查看它时得到的东西

请指导我如何在模板中渲染父子插件,渲染时占位符是否存在任何问题(我的意思是在渲染时是否需要为占位符分配不同的名称?)

  

/Users/Sayan/Library/Python/2.7/lib/python/site-packages/cms/utils/placeholder.py:251:   DuplicatePlaceholderWarning:在以下位置重复{%placeholder“ content”%}   模板fullwidth.html。 DuplicatePlaceholderWarning)

此插件的我的models.py文件:

class ImageUpload(CMSPlugin):
    image_file_1 = models.ImageField()
    pdf_doc_1 = models.FileField()
    pdf_doc_text_1 = models.CharField(max_length=20)
    input_text_1 = models.CharField(max_length=1000)
    button_class = models.CharField(max_length=20)

我的cms_plugins.py文件:

class ImageUploadParentPlugin(CMSPluginBase):
    model = CMSPlugin
    render_template = "image_upload_parent.html"
    allow_children = True


class ImageUploadChildPlugin(CMSPluginBase):
    model = ImageUpload
    require_parent = True
    parent_classes = ['ImageUploadParentPlugin']
    render_template = "image_upload_child.html"
    cache = False

    def render(self, context, instance, placeholder):
        context = super(ImageUploadChildPlugin, self).render(context, 
            instance, placeholder)
        return context

我的image_upload_parent.html文件

{% load cms_tags %}

<div class="intro">
<div class="row">
        {% for plugin in instance.child_plugin_instances %} {% render_plugin plugin %} {% endfor %}
</div>

我的image_upload_child.html文件

<div class="ttfeast col-sm-6 col-xs-12">
<img class="img-responsive" src="{{instance.image_file_1.url}}">
<div class="south-txt">
  {{instance.input_text_1}}
</div>
<div>
    <a href="{{instance.pdf_doc_1.url}}" target="_blank">
        <div class="{{instance.button_class}}">
        {{instance.pdf_doc_text_1}}
        </div>
    </a>
</div>

0 个答案:

没有答案
相关问题