2013-10-02 118 views
0

我试图在我的模板中呈现一个占位符,我已经将它放入了一个自定义CMS插件。问题在于它告诉我'render_placeholder'标记是无效的块标记。无效的块标记:'render_placeholder'

以下是带有'render_placeholder'标记的模板。

{% extends 'base.html' %} 

{% block base_content %} 

<h2>Posts</h2> 
{% if posts %} 
    {% for post in posts %} 
    <div class="entry-list"> 
     {{ post.posted|date:"M d" }} 
     <h3><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h3> 
      {% render_placeholder post.body %} 
     <a href="{{ post.get_absolute_url }}">Read More</a> 
     </div> 
    {% endfor %} 
{% else %} 
    <p>There are no posts.</p> 
{% endif %} 

{% endblock %} 

以下是显示'{%load placeholder_tags%}'的基本模板。

{% load placeholder_tags cms_tags sekizai_tags static menu_tags %} 
<html> 
<head> 
    {% render_block "css" %} 
    <link href="{{ STATIC_URL }}css/styles.css" rel="stylesheet"> 
</head> 
<body> 
    {% show_menu 0 100 100 100 %} 
    {% cms_toolbar %} 
    {% placeholder base_content %} 
    {% block base_content %}{% endblock %} 
    {% render_block "js" %} 
</body> 
</html> 

它一直告诉我“无效块标记:'render_placeholder',预计'空'或'endfor'”。

我是否错过了一些愚蠢的东西?

在此先感谢。

回答

2
{% load placeholder_tags %} 

把它放在您的调用占位符的模板中。

我需要看到你的项目文件夹结构以及确保该标签的来源是可访问的。它应该在名为该文件夹的应用中:

<app_name>/templatetags 
<app_name>/models.py 
+0

非常感谢。我认为“{%load placeholder_tags%}”属于“base.html”,将它移动到扩展“base.html”的另一个模板上。 – alexedwardjones