I am using Django's RSS capabilities to build an RSS feed. The <description>
of the RSS feed items contains HTML markup. Currently, I am just injecting the HTML markup into the feed using the following template:
{{ obj.post }}
Django, of course, translates special characters (<
, >
, &
, etc.) to their respective HTML entities.
I know I could just output the HTML and wrap all the HTML code in <![CDATA[...]]>
sections. This page says that either method is acceptable. If that's true, is there a good reason to pick one method over the other? And if I use example #2, is there a filter for Django to automatically wrap the HTML text in CDATA tags, or should I just change my template to:
<![CDATA[
{{ obj.post|safe }}
]]>
Edit
It seems that Django autoescapes special characters in RSS feeds (or any XML for that matter) no matter what, regardless of whether you pass it through the safe
filter or not (the issue is discussed in this ticket). However, general answers are welcome.