Django 1.4 Feed クラスを使用して、データベース エントリの RSS フィードを返しています。ユーザーが URL で返すフィードの数を指定できるようにしたいのですが、何か試してみましたが、何らかの理由で機能しません。これが私がこれまでに持っているものです:
urls.py
urlpatterns = patterns('',
url(r'^latest/feed/(?P<count>[0-9]+)/$',LatestPostsFeed(),name="feed"),
)
フィード.py
from django.contrib.syndication.views import Feed
from django.core.urlresolvers import reverse
from blog.models import Post
from django.utils import text, html
class LatestPostsFeed(Feed):
title="Latest Posts"
link="feeds"
description="Latest posts"
def items(self,count):
print count
return Post.objects.order_by('-created')[:count]
def item_title(self,item):
return item.title
def item_description(self,item):
return text.truncate_html_words(item.content,50)
def item_link(self,item):
return item.get_absolute_url()
print で count の値を取得しようとすると、サーバーで None が返されます。その値がクラスによって認識されるようにするには、count パラメータをどこに追加すればよいですか?
助けてくれてありがとう。