Opened 18 years ago
Closed 18 years ago
#2878 closed defect (fixed)
Paginator last_on_page fails when .hits hasn't been called
Reported by: | sago | Owned by: | Adrian Holovaty |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | normal | Keywords: | paginator |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Because the last_on_page method relies on self._hits, it crashes when self._hits hasn't been set up yet.
This probably hasn't been seen before because most people call paginator.hits (which sets the ._hits attribute) before calling last_on_page.
All that's needed is to make sure ._hits is valid before proceeding. Calls to ._hits could be
exchanged for calls to .hits, but that would involve multiple calls to the property (and therefore the checking logic) in one go. Better, IMHO, to call self.hits once, then use the value throughout the method.
Patch shows this.
Attachments (1)
Change History (4)
by , 18 years ago
Attachment: | hit_bugfix.patch added |
---|
comment:1 by , 18 years ago
comment:2 by , 18 years ago
Agreed, my vote would be to upgrade the paginator generally. Chris, your patch does that to a large extent.
My patch is a minimal fix.
Maybe we should start a thread on django.users about the requirements for the paginator, and collaborate on a general solution that would help everyone. My requirements may be slightly different from yours, etc. Then we can remove all paginator patches (there are a handful) and submit a canonical solution.
comment:3 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
I'm pretty sure this has been fixed now #2575 has been applied. If you still can identify a problem, please re-open.
Or someone could just apply #2575 which will fix this. However, I won't mark as a dupe because this is fixing a specific problem whereas my one adds some extra functionality as well.