Search code examples
pythondjangofeed

django get_object() takes exactly 2 arguments (3 given) with custom feeds


I'm following the custom Feed example in the book Learning Website Development with Django and learn the necessary changes from old version to Django 1.7.

The feed class i got is:

class UserBookmarks(Feed):

    def get_object(self,bits):
        if len(bits) != 1:
            raise ObjectDoesNotExist
        return User.objects.get(username=bits[0])

    def title(self,user):
        return 'Django Bookmarks | Bookmarks for %s' % user.username

    def link(self,user):
        return '/feeds/user/%s/' % user.username

    def description(self,user):
        return 'Recent bookmarks posted by %s' % user.username

    def items(self,user):
        return user.bookmark_set.order_by('-id')[:10]

And the url configurations:

urlpatterns = patterns('',
      url(r'^feeds(\w*)/$',UserBookmarks()),
)

When I refresh the site, Django gives me a TypeError: get_object() takes exactly 2 arguments (3 given)

I can't figure out where the issue is... please help!


Solution

  • update the get_object signature to

    def get_object(self, request, bits):