Django RSS feed 500错误

时间:2011-08-25 19:26:21

标签: python django rss django-rss

我正在为基于Django的博客设置RSS源。我尝试访问该网址时遇到500错误:

$ curl -I http://172.16.91.140:8000/blogg/feeds/latest/
HTTP/1.0 500 INTERNAL SERVER ERROR

WSGIServer只报告

[25/Aug/2011 20:21:41] "HEAD /blogg/feeds/latest/ HTTP/1.1" 500 0

在blogg /我有两个文件:

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

和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'),
)

知道我哪里可能出错了吗?谢谢你们。

1 个答案:

答案 0 :(得分:0)

我发现了这个问题。调用

return item.subject

意味着有无效的属性,我将其更改为

return item.blog_subject

男生错误。对不起,我也没有包括我的模特。有时写出问题会让我发现一些我忽略的东西。大家快乐编码!