Opened 17 years ago
Closed 17 years ago
#7091 closed (invalid)
Paginator failed to use 'limit' statement for MySQL
Reported by: | 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)
Change History (2)
by , 17 years ago
Attachment: | paginator_patch.diff added |
---|
comment:1 by , 17 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Paginator
is meant to work with any arbitrary iterable of objects, and so cannot assume that aQuerySet
-specific method is available. If you're paginating aQuerySet
, useQuerySetPaginator
instead, which is in the same file and usescount()
.