O'Reilly logo

Django Unleashed by Andrew Pinkham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

28.2 RSS and Atom Feeds

RSS and Atom are two competing formats for feeds. A feed is simply a list of items typically updated and sorted by date. In many ways, the work we will be doing is similar to using the ListView if the generic class-based view (GCBV) didn’t use a template but still output XML that was fully compliant with feed formats.

One of the neat things is that Django supports multiple formats but allows us to only implement a single class for use for both kinds of feeds. To that end, however, we start by extending our model to make the code in the feed a little bit cleaner. We add two methods on Post to format fields in the model, as shown in Example 28.1.

Example 28.1: Project Code

blog/models.py in 3b20644562

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required