Django RSS feed 500 错误

发布于 2024-12-01 17:01:01 字数 1415 浏览 0 评论 0原文

我正在为我的基于 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/ 下,我有两个文件:

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

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

I'm working on setting up an RSS feed for my Django-based blog. 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'^

Any idea where I could be going wrong? Thanks guys.

, 'index'), (r'^(?P<blog_id>\d+)/

Any idea where I could be going wrong? Thanks guys.

, 'detail'), (r'^past-bloggs/', 'country_listing'), (r'^past-bloggs/(?P<country_name>\w+)/

Any idea where I could be going wrong? Thanks guys.

, 'city_listing'), ) urlpatterns += patterns('', url(r'^feeds/(?P<url>.*)/

Any idea where I could be going wrong? Thanks guys.

, 'django.contrib.syndication.views.feed', {'feed_dict': feeds}, name='feeds'), )

Any idea where I could be going wrong? Thanks guys.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心安伴我暖 2024-12-08 17:01:01

我发现了这个问题。调用

return item.subject

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

return item.blog_subject

School boy error。抱歉,我没有也包括我的模型。有时写下问题会让我注意到一些我忽略的事情。大家编码愉快!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文