gpt4 book ai didi

Django 联合 : How do I avoid description escaping?

转载 作者:行者123 更新时间:2023-12-05 00:43:14 25 4
gpt4 key购买 nike

我正在尝试使用 Django 制作网络漫画 RSS 提要,但我无法在描述字段中放置图像,因为 html 代码会被转义,即使它位于 {% autoescape off %} 块中。

这是我的描述模板:

{% autoescape off %}
<img src="{{obj.img.url}}"/>
{% endautoescape %}

这是结果:
&lt;img src="http://localhost:8000/media/comics/001__.png"/&gt;

我怎样才能避免这种自动转义?

最佳答案

How can I avoid this autoescaping?



实际上,您需要保持这种自动转义...仔细查看任何其他 RSS 提要: xkcd.com/rss.xml

Quote from spec RSS 顾问委员会:

A channel may contain any number of items. An item may represent a "story" -- much like a story in a newspaper or magazine; if so its description is a synopsis of the story, and the link points to the full story. An item may also be complete in itself, if so, the description contains the text (entity-encoded HTML is allowed; see examples), and the link and title may be omitted. All elements of an item are optional, however at least one of title or description must be present.



http://www.rssboard.org/rss-encoding-examples

关于Django 联合 : How do I avoid description escaping?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1330975/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com