【问题标题】:Djangocms template not showing upDjangocms 模板未显示
【发布时间】:2015-10-28 05:44:21
【问题描述】:

我有一个基本的 DjangoCMS 正在运行。

base.html 包含:

{% block content %}{% endblock content %}

我也有feature.html:

{% extends "base.html" %}

{% load cms_tags %}

{% block title %}{% page_attribute "page_title" %}{% endblock title %}

{% block content %}
    <div>
        {% placeholder "feature2" %}
    </div>
    <div class="jumbotron"">
        {% placeholder "feature" %}
    </div>
    <div>
        {% placeholder "content" %}
    </div>
{% endblock content %}

我在上面添加了“feature2”占位符,它可以正确显示在网站上进行编辑。

然后我在 base.html 中添加了一个新行:

 {% block base_logo %}{% endblock base_logo %}

并创建了一个新文件 base_logo.html:

{% extends "base.html" %}
{% load cms_tags %}

{% block base_logo %}
    <div>
        {% placeholder logo %}
    </div>
{% endblock base_logo %}

我希望这也会出现在网站上进行编辑,但它没有。我已将 base_logo.html 添加到 settings.py 中的 CMS_TEMPLATES 中,并且 TEMPLATE_DIR 也指向正确。

我还需要做什么才能让 Djangocms 获取我的新模板?

【问题讨论】:

    标签: django django-templates django-cms


    【解决方案1】:

    看看template inheritance。

    您正在尝试使用两个 {% extends %} 标记,这不起作用。您应该为base_logo 使用{% include %} 标记,因为您似乎希望将其包含在许多模板中。 This question 提供更多信息。

    【讨论】:

    • 谢谢,已经用另一种方式解决了这个问题,但很高兴了解包含与扩展。
    猜你喜欢
    • 2014-10-21
    • 2011-06-08
    • 2018-09-02
    • 2019-09-03
    • 1970-01-01
    • 2023-03-28
    • 2011-03-02
    • 2020-06-04
    • 1970-01-01
    相关资源
    最近更新 更多