1 | from django.contrib.syndication.views import Feed
|
---|
2 | from blog.models import Post
|
---|
3 | from django.utils.feedgenerator import Atom1Feed
|
---|
4 |
|
---|
5 | class RssSiteNewsFeed(Feed):
|
---|
6 | title = "blog rss "
|
---|
7 | link = "/blog/rss/"
|
---|
8 | description = "blog rss and atom feeds ."
|
---|
9 |
|
---|
10 | def items(self):
|
---|
11 | return Post.objects.order_by('date')[:10]
|
---|
12 |
|
---|
13 | def item_title(self, item):
|
---|
14 | return item.title
|
---|
15 |
|
---|
16 | def item_description(self, item):
|
---|
17 | return item.description
|
---|
18 |
|
---|
19 | def item_link(self, item):
|
---|
20 | return item.get_absolute_url()
|
---|
21 |
|
---|
22 | class AtomSiteNewsFeed(RssSiteNewsFeed):
|
---|
23 | feed_type = Atom1Feed
|
---|
24 | subtitle = RssSiteNewsFeed.description
|
---|