views:

33

answers:

1

Django 1.2 has brought in some changes in the syndication framework. According to this, I should now be able to do something like:

from django.conf.urls.defaults import *
from myproject.feeds import LatestEntries, LatestEntriesByCategory

urlpatterns = patterns('',
    # ...
    (r'^feeds/latest/$', LatestEntries()),
    (r'^feeds/categories/(?P<category_id>\d+)/$', LatestEntriesByCategory()),
)

But when I try to do anything along those lines, I get an error:

init() takes exactly 3 arguments (1 given)

Can anyone give me a working example? Or perhaps someone understands what this error relates to?

Edit #1

The example above is actually from the Django Advent link. I've tried a variety of things and all of them spout the same error. But a simple non-working example would be:

urls.py

urlpatterns = patterns('',
    url(r'^feeds/comments/$', LatestCommentsFeed()),
)

feeds.py

class LatestCommentsFeed(Feed):
    description = "Latest comments left at %s" % current_site.name
    feed_type = Atom1Feed
    link = "/feeds/comments/"
    title = "%s: Latest comments" % current_site.name

    def items(self):
        return Comment.objects.filter(is_public=True).order_by('-submit_date')[:50]

    def item_pubdate(self,item):
        return item.submit_date

    def item_guid(self,item):
        return "tag:%s,%s:%s" % (current_site.domain,
                                 item.submit_date.strftime('%Y-%m-%d'),
                                 item.get_absolute_url())
+1  A: 

Ok, found the culprit! :) In my feeds.py I had:

from django.contrib.syndication.feeds import Feed

And I should have had:

from django.contrib.syndication.views import Feed

The django.contrib.syndication.feeds module is there only for backwards compatibility apparently.

Monika Sulik