2

我正在为基于 Django 的博客设置 RSS 提要。尝试访问 URL 时出现 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/ 我有两个文件:

提要.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'),
)

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

4

1 回答 1

0

我发现了这个问题。打电话

return item.subject

意味着存在无效属性,我将其更改为

return item.blog_subject

小学生错误。抱歉,我也没有包括我的模型。有时写出一个问题会让我注意到一些我忽略的东西。祝大家编码愉快!

于 2011-08-25T21:01:45.557 回答