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.
Get Django Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.