Django RSS feed 500 error
I'm working on setting up an RSS feed for my Django-based blog开发者_如何学Python. I'm getting 500 errors when I try and access the URL:
$ curl -I http://172.16.91.140:8000/blogg/feeds/latest/
HTTP/1.0 500 INTERNAL SERVER ERROR
WSGIServer is reporting nothing more than
[25/Aug/2011 20:21:41] "HEAD /blogg/feeds/latest/ HTTP/1.1" 500 0
Under blogg/ I've got two files:
feeds.py:
from django.contrib.syndication.feeds import Feed
from blog.models import *
class BlogFeed(Feed):
title = "Test Title"
link = "/sitenews/"
description = "Test Description"
def items(self):
return Blog.objects.filter( is_published = True ).order_by('-id')[:10]
def item_title(self, item):
return item.subject
def item_description(self, item):
return item.subject
def item_pubdate(self,item):
return item.blog_time
and urls.py
from django.conf.urls.defaults import patterns, include, url
from blog.feeds import *
feeds = {
'latest': feeds.BlogFeed,
}
urlpatterns = patterns('blog.views',
(r'^$', 'index'),
(r'^(?P<blog_id>\d+)/$', 'detail'),
(r'^past-bloggs/', 'country_listing'),
(r'^past-bloggs/(?P<country_name>\w+)/$', 'city_listing'),
)
urlpatterns += patterns('',
url(r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feeds}, name='feeds'),
)
Any idea where I could be going wrong? Thanks guys.
I found the issue. Calling
return item.subject
Meant there was an invalid property, I changed it to
return item.blog_subject
School boy error. Sorry I hadn't included my model as well. Sometimes writing out a problem will cause me to notice something I've overlooked. Happy coding everyone!
精彩评论