from django.contrib.sites.models import Site
from django.contrib.syndication.views import Feed, add_domain
-from django.utils.feedgenerator import Atom1Feed
+from django.utils.feedgenerator import Atom1Feed, Rss201rev2Feed
from haystack.query import SearchQuerySet
from jsonresponse import to_json
newsitem = NewsItemDetailView.as_view()
+class RssCustomPodcastsFeed(Rss201rev2Feed):
+ def root_attributes(self):
+ attrs = super(RssCustomPodcastsFeed, self).root_attributes()
+ attrs['xmlns:dc'] = 'http://purl.org/dc/elements/1.1/'
+ return attrs
+
+ def add_item_elements(self, handler, item):
+ super(RssCustomPodcastsFeed, self).add_item_elements(handler, item)
+ for tag in item.get('tags') or []:
+ handler.addQuickElement('dc:subject', tag)
class PodcastsFeed(Feed):
title = 'Radio Panik - Podcasts'
link = '/'
description_template = 'feed/soundfile.html'
+ feed_type = RssCustomPodcastsFeed
def items(self):
return SoundFile.objects.select_related().filter(
def item_pubdate(self, item):
return item.creation_timestamp
+ def item_extra_kwargs(self, item):
+ return {'tags': [x.name for x in item.episode.tags.all()]}
+
podcasts_feed = PodcastsFeed()