#35733: Page.__len__ could skip a query if self.paginator.count == 0
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Jacob
Type: | Walls
Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Jacob Walls):
> Or maybe it's not necessary because a page cannot be created without
count being cached in the first place?
That's more or less what I found, except that it is ''possible'' to
manually instantiate a `Page`, just unlikely enough that it may not be
worth coding around?
The recommend interface is to create the `Page` via `Paginator.page()` (or
`Paginator.get_page()` and `Paginator.__iter__()` which call it), any of
which in turn cache the count via `validate_number()`:
{{{
You usually won't construct ``Page`` objects by hand -- you'll get them by
iterating :class:`Paginator`, or by using :meth:`Paginator.page`.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35733#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070191c48a6473-01abda75-c69c-4992-a143-2a103457718f-000000%40eu-central-1.amazonses.com.