Opened 17 years ago

Closed 17 years ago

#7091 closed (invalid)

Paginator failed to use 'limit' statement for MySQL

Reported by: nicholasdsj@… Owned by: nobody
Component: Core (Other) Version: dev
Severity: Keywords: paginator mysql
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

# paginator.py:36
    def _get_count(self):
        "Returns the total number of objects, across all pages."
        if self._count is None:
            self._count = len(self.object_list)
        return self._count
    count = property(_get_count)

len(self.object_list) will force a query without 'limit' statement, it's very severe problem. Instead of using len() method, an alternative way is to use self.object_list.count()

Attachments (1)

paginator_patch.diff (462 bytes ) - added by nicholasdsj@… 17 years ago.

Download all attachments as: .zip

Change History (2)

by nicholasdsj@…, 17 years ago

Attachment: paginator_patch.diff added

comment:1 by James Bennett, 17 years ago

Resolution: invalid
Status: newclosed

Paginator is meant to work with any arbitrary iterable of objects, and so cannot assume that a QuerySet-specific method is available. If you're paginating a QuerySet, use QuerySetPaginator instead, which is in the same file and uses count().

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