Django syndication: How do I avoid the escaping description?

I am trying to create a webcomic RSS feed with Django, but I canโ€™t put the image in the description field because the html code gets the escape code even if it is in the {% autoescape off%} block.

Here is my description template:

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

And this is the result:

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

How to avoid this auto protection?

+4
source share
2 answers

How to avoid this auto protection?

In fact, you need to save this auto-escaping ... Look carefully at any other rss feeds: xkcd.com/rss.xml

Quote from the specification by the RSS Advisory Board:

A channel can contain any number of items. An element can be a โ€œstoryโ€ - like a story in a newspaper or magazine; if so, a brief overview of the story, and the link points to the full story. An element can also be filled in itself; if so, the description contains text ( entity-encoded HTML code is allowed ; see examples ), and the link and title can be omitted. All elements of the element are optional, however at least one of the titles or a description should be provided.

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

+6
source

This seems to have nothing to do with autoescaping, as it will never โ€œrun awayโ€ the hard-coded tags that you explicitly specified in your template, like you are here.

I suspect something is even further down the line that makes the escape. Can you post code that displays a template and does something with the result?

0
source

All Articles