生成RSS feed ... django / python

时间:2012-07-30 15:59:08

标签: python django rss

我没有使用常规模型,所以不能使用Django的联合框架。所以,我确实使用了名为feedgenerator的低级联合工具来生成RSS feed,如下所示。

feed = feedgenerator.Rss201rev2Feed(title=_("Feed by %s") % user.username,
        link="http://%s" % DOMAIN_NAME,
        description=_("RSS Feed provided by something.com"),
        language=user.language, 
        author_name=user.full_name, 
        feed_url="something")

    for note in ObjectModel.published_objects.filter(user=user):
        feed.add_item(title=note.title,
            link="",
            pubDate=note.created,
            description=note.note)
    response = HttpResponse(feed.writeString('UTF-8'), mimetype='application/rss+xml')
    return response

但是,我找不到一个好的例子,我怎么能把它作为Response类型返回。

response = HttpResponse(feed.writeString('UTF-8'), mimetype='application/rss+xml')

显然,上面的代码似乎不正确,因为浏览器无法识别为RSS提要。有人能告诉我应该怎么做才能解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

这只是工作正常。可以被浏览器识别。