Django feeds as class based views, now part of Django 1.2.
Python JavaScript Shell
Latest commit f255035 Aug 6, 2010 @bfirsh Fixed import for 1.1.x
Permalink
Failed to load latest commit information.
doc Initial documentation. Dec 13, 2009
syndication Fixed import for 1.1.x Aug 6, 2010
.gitignore Created gitignore May 7, 2009
LICENSE Added license, readme and setup.py Nov 4, 2009
MANIFEST.in added a MANIFEST.in to include other files Jul 6, 2010
README.md Fixed compatibility with Django 1.1.x. Jul 28, 2010
run_tests.sh
setup.py use development release versioning to reduce conflict with anything d… Jul 6, 2010

README.md

syndication-view

syndication-view is a refactor of Django's syndication contrib app, primarily to turn feeds into class-based views, but also fixes a number of long standing tickets.

As of revision 12338, syndication-view is a part of Django and is included in version 1.2. This repository is maintained as a backport for Django 1.1.x.

Installation

$ python setup.py install

Usage

articles/feeds.py:

from syndication.views import Feed
from articles.models import Article, Category

class ArticleFeed(Feed):
    title = "example.com news"
    link = "/sitenews/"
    description = "Latest news from example.com."

    def items(self):
        return Article.objects.all()[:15]
    
class CategoryArticleFeed(ArticleFeed):
    def title(self, obj):
        return 'example.com: %s' % obj
    
    def get_object(self, request, slug):
        return Category.objects.get(slug=slug)
    
    def items(self, obj):
        return Article.objects.filter(category=obj)[:15]

urls.py:

from articles.feeds import ArticleFeed, CategoryArticleFeed

urlpatterns = patterns('',
    # ...
    (r'^articles/feed/$', ArticleFeed()),
    (r'^articles/feed/(?P<slug>[a-z0-9\-]+)/$', CategoryArticleFeed()),
    # ...
)

The API for the feed object in syndication.views is almost identical to that in Django's contrib app, except get_object() takes the request and any arguments passed to it from the URL rather than the "bits".