I made this app that is supposed to give an xml document with 5 items. My view sends a dictionary ‘rsscontent’ with these five items to the file rss.xml:
#views.py
return render_to_response("rss.xml", {"rsscontent":rsscontent})
Then the rss.xml file looks like this:
#rss.xml
<?xml version="1.0" encoding="UTF-8"?>
<rss version="0.92">
<channel>
{% for key, value in rsscontent.items %}<item>
<title>{{value|safe}}</title>
<description>{{value|safe}}</description>
<link>{{key|safe}}</link>
</item>
{% endfor %}
</channel>
</rss>
It generates an output, however the page is acting weird. The output has [u”] in it like this:
<title>[u'Apple iPod touch 8 GB (4th Generation) NEWEST MODEL']</title>
<description>[u'Apple iPod touch 8 GB (4th Generation) NEWEST MODEL']</description>
How can I remove this? and make sure it is normal text?
Don’t use the
|safefilter. Additionally, it looks like your object values are lists, so you’ll need to get the first element of those, rather than just printing the items themselves.You want to modify your input
rsscontentvariable to look like this:rather than your current that probably has:
If you can’t do that, you need to modify your template value outputs to look like this:
This gets the first item in the list, rather than printing the list itself.