특정 태그 아래에 블로그 게시물의 최신 항목 피드를 생성하려고합니다. 나는 장고 태깅을 사용했다. 내가 어떻게 할 수 있니? 여기에 내가 정의하는 방법입니다 내 LatestEntriesFeeddjango는 특정 태그에 대한 피드를 생성합니다.
from django.core.exceptions import ObjectDoesNotExist
from django.utils.feedgenerator import Atom1Feed
from django.contrib.sites.models import Site
from django.contrib.syndication.feeds import Feed
from articles.models import Entry
current_site = Site.objects.get_current()
class LatestEntriesFeed(Feed):
title = 'Latest Entries for %s' % current_site
link = '/feeds/latest/'
description = 'Latest entries posted.'
def items(self):
return Entry.live.all()[:100]
def item_pubdate(self, item):
return item.pub_date
def item_guid(self, item):
return "tag:%s,%s:%s" % (current_site.domain,
item.pub_date.strftime('%Y-%m-%d'),
item.get_absolute_url())
도움이 될만한 정보를 주신 alex에게 감사드립니다. LatestEntriesFeed를 서브 클래 싱하는 것을 생각하고 있습니다. –