Django-way of specifying channel image in rss feed

前端 未结 3 2090
北荒
北荒 2021-02-08 12:19

What is the \"django-way\" of specifying channel image in rss feed? I can do it manually by rolling my own xml, but was looking for a proper way of doing it.

Edit

3条回答
  •  死守一世寂寞
    2021-02-08 12:38

    Found the right way of doing it. As the documentation describes, I needed to create a custom feed generator by subclassing from Rss201rev2Feed and overriding method

    add_root_elements()
    

    like this:

    class RssFooFeedGenerator(Rss201rev2Feed):
        def add_root_elements(self, handler):
            super(RssFooFeedGenerator, self).add_root_elements(handler)
            handler.addQuickElement(u"image", '',
                {
                     'url': u"http://www.example.com/images/logo.jpg",
                     'title': u"Some title",
                     'link': u"http://www.example.com/", 
                 })     
    
    class RssFooFeed(Feed):
        feed_type = RssFooFeedGenerator
        title = u"Foo items"
        link = u"http://www.example.com/"
        description = u"Some description"
    

提交回复
热议问题