from django db import models from django contrib syndication feeds imp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from django.db import models
from django.contrib.syndication.feeds import Feed
from django.utils.feedgenerator import Atom1Feed
from tagging.models import Tag
from tagging.models import TaggedItem
from tagging.fields import TagField
class News(models.Model):
theme = models.CharField(max_length=200)
text = models.TextField()
pub_date = models.DateTimeField('date published')
tags = TagField()
def get_absolute_url(self):
return "/blog/%i/" % self.id
def __unicode__(self):
return self.theme
def tag_list(self):
return self.tags.split()
class LatestEntries(Feed):
title = "Valeriy Shvets's Blog"
link = "/sitenews/"
description = "My firs blog..."
def items(self):
return News.objects.order_by('-pub_date')[:5]
class AtomSiteNewsFeed(LatestEntries):
feed_type = Atom1Feed
subtitle = LatestEntries.description