Django1.5 关于from django.contrib.syndication.views import Feed 的变更 1.5中只有views.py一个文件,其他的在1.5都删除了 A simple example This simple example, taken from a hypothetical police beat news site describes a fee
Django1.5 关于from django.contrib.syndication.views import Feed 的变更
1.5中只有views.py一个文件,其他的在1.5都删除了
A simple example
This simple example, taken from a hypothetical police beat news site describes a feed of the latest five news items:
from django.contrib.syndication.views import Feedfrom django.core.urlresolvers import reverse
from policebeat.models import NewsItem
class LatestEntriesFeed(Feed):
title = "Police beat site news"
link = "/sitenews/"
description = "Updates on changes and additions to police beat central."
def items(self):
return NewsItem.objects.order_by('-pub_date')[:5]
def item_title(self, item):
return item.title
def item_description(self, item):
return item.description
# item_link is only needed if NewsItem has no get_absolute_url method.
def item_link(self, item):
return reverse('news-item', args=[item.pk])
1.4以前
from django.contrib.syndication.views import feed