Wednesday, September 29, 2010

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

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)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment