Django 学习笔记(六)

来源:互联网 发布:linux 播放 4k 视频 编辑:程序博客网 时间:2024/05/21 17:42

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 reversefrom policebeat.models import NewsItemclass 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

原创粉丝点击