Django Syndication Framework
by Justin Michalicek on Aug. 11, 2011, 6:34 a.m. UTCI've been looking for more to do with Django. I took a look at some of the common additional addons for Django and decided to use the syndication framework to add an RSS feed of the latest posts.
This basic usage was pretty simple to get up and running. It required adding one simple class which inherits from django.contrib.syndication.views.Feed, which I put in a new feeds.py file, and of course adding a line to urls.py.
from django.contrib.syndication.views import Feed from cms.models import * class BlogFeedRss(Feed): """RSS feed of latest posts""" title = "Bash-Shell.Net Posts" link = "/feed/rss/" description = "Latest bash-shell.net posts" def items(self): #This method gets called when the rss feed is accessed return Post.objects.order_by('-created_date')[:5] def item_title(self, item): #called when the title of an item in the feed is needed return item.title def item_description(self,item): #Just like it sounds like, as above return u'%s...' %(item.text_html[:250])