0

(of )を使用してdjango.contrib.syndication.viewsCache-ControlにHTTP ヘッダーを設定しようとしましたが、無駄でした:cache_control()django.views.decorators.cache

from django.contrib.syndication.views import Feed
from django.utils.feedgenerator import Atom1Feed
import lxml.html
import requests

class TestFeed(Feed):
    feed_type = Atom1Feed
    language = 'zh-Hant-TW'
    link = 'https://www.example.com/feed'
    title = 'Sample feed'

    def items(self):
        s = requests.Session()
        r = s.get(self.link)
        body = lxml.html.fromstring(r.text)
        items = body.cssselect('.item a')

        return items

    def item_description(self, item):
        img = item.cssselect('img')[0]
        img.set('src', img.get('data-src'))
        content = lxml.etree.tostring(item, encoding='unicode')

        return content

    def item_link(self, item):
        link = item.get('href')

        return link

    def item_title(self, item):
        title = item.get('title')

        return title

django.contrib.syndication.views のソース コードをトレースした後、デコレータを使用して HTTP ヘッダーを HTTP 応答オブジェクトに追加する可能性は低いようです。

これを達成するための回避策はありますか?

4

0 に答える 0