【发布时间】:2013-08-13 01:46:32
【问题描述】:
当DEBUG=True 包含HTML 的变量只是打印在模板中并且不 插入为HTML。这是正确的行为。
另一方面,当DEBUG=False(只是改变这个)变量的内容被解释为HTML,我不明白为什么。我没有使用safe 过滤器。
我的模板如下:
<pre id="copy-source-{{ forloop.counter }}">
<code>{{ code }}</code>
</pre>
在一种情况下,code 恰好是 HTML 代码,具体来说:
<a href="blabla"><img src="bblabla" /></a>
页面显示图像而不是代码,即使它在预代码中!?
【问题讨论】:
-
你用的是什么 django 版本?
-
@alecxe: 1.5.1,抱歉没有包括在内。
-
@alecxe:更新了问题。谢谢
标签: html django templates django-templates