django - 逐字包含模板

标签 django django-templates

我有一个模板,我正在插入包含标签:

{% include 'template.html' %}

同样在另一个地方,我希望其内容显示为原始内容。我怎样才能做到这一点?

最佳答案

您可以尝试以下操作:

页面1.html

{%with flag="norender" %}
    {% include "template.html" %}
{%endwith%}

模板.html
{%if flag == "norender" %}
    {%verbatim%}
{%endif%}
        {#your html #}
{%if flag == "norender" %}
    {%endverbatim%}
{%endif%}

关于django - 逐字包含模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17130803/

相关文章:

python - Django Form 'initial' 和 'bound data' 之间的区别?

python - 无法将页面从主页转移到关于页面

Django 管理员 : Customizing the inline template (tabular. html)

python - 更改 Django 查询集的结构

ajax - django/ajax : Unable to get Ajax post data in the views. py

database - 在 Mac OS X 上用 django 部署最简单的数据库是什么?

python - 使用 django 和 sqlite 的运行时问题 - 查询过多

django - 可重用的应用程序,仅在未定义时定义 block

python - 'utf- 8' codec can' t 解码字节 - Python

Django - 匿名用户组