Opened 9 years ago

Closed 9 years ago

#4404 closed (fixed)

LatestCommentsFeed causing AssertionError due to slicing

Reported by: Stuart Williams <stuart@…> Owned by: adrian
Component: contrib.comments Version: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by mtredinnick)

LatestCommentsFeed from contrib/comments/ calls upon LatestFreeCommentsFeed, which slices the result. This causes an AssertionError:

Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/django/core/handlers/"
in get_response
  77. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.5/site-packages/django/contrib/syndication/" in feed
  19. feedgen = f(slug, request.path).get_feed(param)
File "/usr/lib/python2.5/site-packages/django/contrib/syndication/" in get_feed
  94. for item in self.__get_dynamic_attr('items', obj):
File "/usr/lib/python2.5/site-packages/django/contrib/syndication/" in __get_dynamic_attr
  51. return attr()
File "/usr/lib/python2.5/site-packages/django/contrib/comments/" in items
  36. qs = qs.filter(is_removed=False)
File "/usr/lib/python2.5/site-packages/django/db/models/" in
  368. return self._filter_or_exclude(None, *args, **kwargs)
File "/usr/lib/python2.5/site-packages/django/db/models/" in
  381. "Cannot filter a query once a slice has been taken."

  AssertionError at /rss/comments/
  Cannot filter a query once a slice has been taken. 

Sorry about the lack of further details, but I'm pretty new to both Python and Django... Thanks!

Attachments (1)

4404.patch (1.1 KB) - added by SmileyChris 9 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 9 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Thanks for the report, Stuart. Glad we got to the bottom of this (this ticket follows an IRC troubleshooting session)

comment:2 Changed 9 years ago by SmileyChris

To explain the problem, LatestCommentsFeed.items is getting a sliced queryset (from LatestFreeCommentsFeed.items) and then trying to filter on it. Which you can't do.

Here comes the patch...

Changed 9 years ago by SmileyChris

comment:3 Changed 9 years ago by SmileyChris

  • Has patch set
  • Triage Stage changed from Accepted to Ready for checkin

comment:4 Changed 9 years ago by mtredinnick

  • Description modified (diff)

comment:5 Changed 9 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(In [5408]) Fixed #4404 -- Fixed LatestCommentsFeed query problem. Thanks, SmileyChris.

Note: See TracTickets for help on using tickets.
Back to Top