Reputation: 11
I am a beginner. I want to add a RSS function to my blog. It shows an RSS page but it shows no entries. I don't know why. My urls.py
is:
feeds = {'latest': PostAtomFeed, }
...
url(r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feeds}),
And feeds.py
:
from django.contrib.syndication.feeds import Feed
from myproject.myblog.models import Blog
from django.contrib.sites.models import get_current_site
from django.utils.feedgenerator import Atom1Feed
class PostRssFeed(Feed):
title = "Run and Hide"
description = "Latest Blog Entries"
link = 'http://' + get_current_site(None).domain + '/blog/'
def items(self):
return Blog.objects.all().order_by('-pub_date')[:10]
def item_title(self, item):
return item.title
def item_description(self, item):
return item.description
class PostAtomFeed(PostRssFeed):
feed_type = Atom1Feed
subtitle = PostRssFeed.description
My blog entry address is like this: http://127.0.0.1:8000/blog/1/
But when I go to http://127.0.0.1:8000/feeds/latest/
, I get this:
I really don't know how to fix it. Any ideas?
Upvotes: 0
Views: 266
Reputation: 11
I have fix it! I defined a wrong get_absolte_url() in my models.
Now, it works well.
Upvotes: 1