Django feed templates and how do I use them with images?

475 views
Skip to first unread message

PeterR

unread,
Sep 15, 2010, 6:25:40 AM9/15/10
to Django users
Hi,

I like to generate a feed with text and image. My objective is the
communication between a client and the RSS feed django server.

Similar to text, you find at feedparser the following explanation for
a image in a RSS feed:

>>

This is a feed image:

<image>
<title>Feed logo</title>
<url>http://example.org/logo.png</url>
<link>http://example.org/</link>
<width>80</width>
<height>15</height>
<description>Visit my home page</description>
</image>

This feed image could be rendered in HTML as this:

<a href="http://example.org/">
<img src="http://example.org/logo.png"
width="80"
height="15"
alt="Feed logo"
title="Visit my home page">
</a>

I like to ask which part is what I need to include in the Django feed
template ?? The explanation of feed templates is somehow very short?
Should I have two templates, one for RSS(XML) and one for HTML?

Thank you for your help.

Peter
Message has been deleted

Lisa B

unread,
Sep 29, 2010, 1:12:37 PM9/29/10
to Django users
Not exactly what you want, but if you are trying to publish images in
your RSS feed with each item: I did this by putting an <img> tag
inside the description. Look at the way they did the feed here:
http://ciclops.org/rssfeed.php this feed w3c validates and seems to
work as desired everywhere I've tried it (feedly, Ning, firefox's
display of the feed)

Code is just the ordinary from the docs:

class LatestImagesFeed(Feed):
title = "feed title"
link = "mysite.com"
description = "Feed Description"

def items(self):
return Image.objects.filter(pub_date__isnull=False).order_by('-
pub_date')[:10]

def item_title(self, item):
return item.title

def item_description(self, item):
desc ='<img width = "144" src = "' + 'http://
media.mysite.com/' + str(item.jpg) + '"> '
desc += str(item.Description)
return desc

def item_link(self,item):
return 'http://mysite.com/' + str(item.pub_date)

Reply all
Reply to author
Forward
0 new messages