Net*_*zen 1 django django-urls django-syndication django-rss
我按照本教程了解了django的RSS和ATOM提要,然后我开始工作了.
但是,测试开发服务器不断使浏览器将提要下载为文件,而不是浏览器将其检测为xml文档.
我使用HTTP的经验告诉我,Content-Type标头中缺少mime类型.
如何在django中指定?
小智 10
Everyblock源代码中有关于此的注释.
它们定义了一个替换标准Django feed的mime类型的类,如下所示:
# RSS feeds powered by Django's syndication framework use MIME type
# 'application/rss+xml'. That's unacceptable to us, because that MIME type
# prompts users to download the feed in some browsers, which is confusing.
# Here, we set the MIME type so that it doesn't do that prompt.
class CorrectMimeTypeFeed(Rss201rev2Feed):
mime_type = 'application/xml'
# This is a django.contrib.syndication.feeds.Feed subclass whose feed_type
# is set to our preferred MIME type.
class EbpubFeed(Feed):
feed_type = CorrectMimeTypeFeed
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4561 次 |
| 最近记录: |