TEXT   258
from django contrib syndication views import Feed
Guest on 2nd December 2024 07:14:44 AM


  1. from django.contrib.syndication.views import Feed
  2.     from django.core.urlresolvers import reverse
  3.     from policebeat.models import NewsItem
  4.  
  5.     class LatestEntriesFeed(Feed):
  6.         title = "Police beat site news"
  7.         link = "/sitenews/"
  8.         description = "Updates on changes and additions to police beat central."
  9.  
  10.         def items(self):
  11.             return NewsItem.objects.order_by('-pub_date')[:5]
  12.  
  13.         def item_title(self, item):
  14.             return item.title
  15.  
  16.         def item_description(self, item):
  17.             return item.description
  18.  
  19.         # item_link is only needed if NewsItem has no get_absolute_url method.
  20.         def item_link(self, item):
  21.             return reverse('news-item', args=[item.pk])

Raw Paste

Login or Register to edit or fork this paste. It's free.