Django-way of specifying channel image in rss feed

前端 未结 3 2100
北荒
北荒 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:30

    I suggesting to use django-atompub for Atom feed generation. It has very nice Class abstraction with lots of options, so no any XML hacking, high-level Python code only.

    Example:

    # Define feed class
    class StreamFeed(Feed):
        ... [snipped]
        def item_links(self, item):
            return [{'rel': 'enclosure', 'href': item.file.url, 'length': item.file.size, 'type': item.mime.name},
            {'rel': 'alternate', 'href': full_url(item.get_absolute_url())}]
    

    I used it in my open source photoblog django app. You can see examples via bitbucket repo.

    Complete feed generation code.

提交回复
热议问题