root/branches/pluggable-contents/blog/feeds.py

Revision 19, 0.7 kB (checked in by nobu, 1 year ago)

fixed #9

  • RSS2.0で実装。
  • テストの更新。
Line 
1 # vim: encoding=utf-8 :
2
3 from django.contrib.sites.models import Site
4 from django.contrib.syndication.feeds import Feed
5 from django.utils.translation import ugettext_lazy as _
6
7 from blog.models import Entry
8
9 CURRENT_SITE = Site.objects.get_current()
10
11 class LatestEntries(Feed):
12     """
13     Generate feed.
14     """
15     link = '/'
16     title = _(u'Latest entries - %s') % CURRENT_SITE.name
17     description = _(u'The latest entries on %s') % CURRENT_SITE.name
18     title_template = 'blog/feeds_title.html'
19     description_template = 'blog/feeds_description.html'
20
21     def items(self):
22         return Entry.objects.filter(is_published__exact=True)\
23                             .filter(is_active__exact=True)[:30]
Note: See TracBrowser for help on using the browser.