I’m creating yet another website in Django, mostly for fun. One of the things I wanted this website to have was an RSS feed. I glanced at the documentation for generating a feed from Django and was initally put off because it looked a little cumbersome. I then began investigating my other options, like generating the feed manually, and decided to give the Django syndication doc a fuller read. I’m very glad that I did. The reason that Django’s RSS generation looked cumbersome at first glance is because it is featureful, flexible, and has every option you will probably need.

In order to create an RSS feed, all I needed to do was create a “feeds” dictionary in my url.conf:

feeds = {
'articles': ArticlesFeed,
'blog': BlogFeed,
'podcasts': PodcastFeed,
}

a URL pattern:

urlpatterns = patterns('',
##lot of URL configuration omitted here
(r'^feeds/(?P.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feeds}),
)

and a few Feed objects. Here is an example of one:

class BlogFeed(Feed):
title = "Blog Title"
link = "/blog/"
description = "My random thoughts and musings on a variety of subjects."
def items(self):
return get_items("blog")

And everything just works. I tested my feeds with Blam and Sage and they work just fine. I also created a feed with enclosures and both iPodder and a custom podcast grabber I created had no problems with the feed. I can’t imagine this being easier.