在rss feed中指定频道图像的Django方式 [英] Django-way of specifying channel image in rss feed
本文介绍了在rss feed中指定频道图像的Django方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在rss feed中指定频道图像的django-way是什么?我可以通过滚动我自己的xml来手动执行,但是正在寻找一种正确的方法。
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.
编辑
dobrych的解决方案在这里不太适用,因为我正在特别询问RSS而不是Atom订阅源
Edit dobrych's solution is not quite applicable here because I was asking specifically about RSS not Atom feeds
推荐答案
找到 >做的方式由于文档描述,我需要通过从 Rss201rev2Feed 和覆盖方法
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()
像这样:
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"
这篇关于在rss feed中指定频道图像的Django方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文