Django 联合:如何避免描述转义?
我正在尝试使用 Django 制作网络漫画 RSS 提要,但我无法将图像放入描述字段中,因为 html 代码会被转义,即使它位于 {% autoescape off %} 块中。
这是我的描述模板:
{% autoescape off %}
<img src="{{obj.img.url}}"/>
{% endautoescape %}
这就是结果:
<img src="http://localhost:8000/media/comics/001__.png"/>
如何避免这种自动转义?
I'm trying to make a webcomic RSS feed with Django, but I can't put an image in the description field, because the html code gets escaped, even if it's in an {% autoescape off %} block.
Here is my description template:
{% autoescape off %}
<img src="{{obj.img.url}}"/>
{% endautoescape %}
And this is the result:
<img src="http://localhost:8000/media/comics/001__.png"/>
How can I avoid this autoescaping?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实际上,您需要保持这种自动转义...仔细查看任何其他 rss 提要:xkcd.com/rss。 xml
引自 RSS 咨询委员会规范:
http://www.rssboard.org/rss-encoding-examples
Actually, you need to keep this auto-escaping... Look carefully at any other rss feeds: xkcd.com/rss.xml
Quote from spec by the RSS Advisory Board:
http://www.rssboard.org/rss-encoding-examples
这似乎与自动转义没有任何关系,因为这永远不会“转义”您在模板中显式输入的硬编码标签,如下所示。
我怀疑有更进一步的东西正在逃跑。您可以发布呈现模板并对结果执行某些操作的代码吗?
This doesn't seem to have anything to do with autoescaping, as that would never 'escape' the hard-coded tags that you entered explicitly in your template as you have here.
I suspect there's something further down the line that is doing the escaping. Can you post the code that renders the template and does something with the result?