2009-06-27 4 views
1

私はthis tutorialに続き、djangoのRSSフィードとATOMフィードのために働いています。Django:RSSとATOMはContent-Typeヘッダをフィードしますか?

しかし、テスト開発サーバーは、ブラウザがxmlドキュメントとしてそれを検出する代わりに、フィードをファイルとしてダウンロードし続けるようにしています。

私のHTTPの経験から、Content-TypeヘッダーにMIMEタイプがないことがわかります。

djangoでどのように指定しますか?

+0

私はそこrender_to_responseのMIMEタイプパラメータがあるが、それは、Djangoのシンジケーションのために使用されていません知っている:

は、彼らはとても似フィード標準のDjangoのMIMEタイプを置き換えるクラスを定義します。 –

+0

Django 'contrib.syndication'はフィードのための適切なコンテンツタイプヘッダを設定します。生のブラウザよりも正確なツールでもう一度チェックしてください。 –

+0

私はFirefoxで同じ問題を抱えています。 mimetypeはATOMのapplication/atom + xmlでなければなりません。 私はGET/page/rss /を使ってページを呼び出すときにうまく動作しますが、POST FFでそのファイルをダウンロードしようとしています。 – zinovii

答えて

1

のようなものがあるがOS Xではなく、HTTPヘッダーとMIMEタイプを使用します。

Safariを試してみると、うまくいきました。

1

あなたはそのコンテンツタイプを指定することができますHTTPReponseオブジェクトの作成:

HttpResponse(content_type='application/xml') 

または任意のコンテンツタイプが実際にあるの。

http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpResponse.__init__

+0

上記のとおり、Djangoでシンジケーションを使用するHttpResponseやrendr_to_responseコールは使用しません。 –

3

あなたはRSSために利用可能なビューを使用していますか? これは私が私のurls.pyに持っているものである - そして私は、MIMEタイプについては何も設定していないです:

published_feeds
urlpatterns += patterns('', 
    (r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': published_feeds}, 'view_name')`, 
) 

私は問題はカミノブラウザ上でだったと思います

class LatestNewsFeed(Feed): 
    def get_object(self, bits): 
     pass 

    def title(self, obj): 
     return "Feed title" 

    def link(self, obj): 
     if not obj: 
     return FeedDoesNotExist 
     return slugify(obj[0]) 

    def description(self, obj): 
     return "Feed description" 

    def items(self, obj): 
     return obj[1] 

published_feeds = {'mlist': LatestNewsFeed} 
9

これについてEveryblockのソースコードにコメントがあります。

# 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 
関連する問題