RSS With the Syndication Framework
Create feed.py
vim post/feed.py
from django.contrib.syndication.views import Feed
from post.models import *
class LastestPostFeed(Feed):
title="my blog"
link="http://www.xxxxx.com"
description="my blog about something"
def items(self):
return Post.objects.all().order_by('-id')[:10]
def item_title(self,item):
return item.title
def item_description(self,item):
return item.body
def item_link(self,item):
return 'http://example.com/%s' % item.slug
vim urls.py
from post.feeds import LastestPostFeed url(r'^rss/mian',LastestPostFeed()),
python manage.py runserver
localhose:8000/rss/main