在rss feed中指定 channel 图片的“django-way”是什么?我可以通过滚动自己的xml来手动完成此操作,但一直在寻找正确的方法。
编辑
dobrych的解决方案在这里不太适用,因为我专门询问的是RSS而非Atom提要
最佳答案
找到正确的方法。正如documentation所描述的,我需要通过从Rss201rev2Feed和覆盖方法的子类创建一个自定义的提要生成器
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"