#27814 closed Bug (fixed)
Unclear explanation of orphans in Paginator
Reported by: | Pablo Oubiña | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | 1.10 |
Severity: | Normal | Keywords: | paginator, orphans, |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hi there!
From Django documentation:
"Paginator objects
...
orphans
The minimum number of items allowed on the last page, defaults to zero..."
Current implementation:
>>> from django.core.paginator import Paginator >>> objects = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'] >>> p = Paginator(objects, 3, orphans=2) >>> page2 = p.page(2) >>> page2.object_list output: ['d', 'e', 'f', 'g', 'h'] >>> page2.has_next() output: False
As I understand it:
>>> from django.core.paginator import Paginator >>> objects = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'] >>> p = Paginator(objects, 3, orphans=2) >>> page2 = p.page(2) >>> page2.object_list output: ['d', 'e', 'f'] >>> page2.has_next() output: True >>> page3 = p.page(3) >>> page3.object_list output: ['g', 'h']
In my opinion, the orphans definition is confusing. What do you think? Am I missing something?
Thanks.
Change History (6)
follow-up: 2 comment:1 by , 8 years ago
Triage Stage: | Unreviewed → Accepted |
---|---|
Type: | Uncategorized → Bug |
comment:2 by , 8 years ago
Replying to Tim Graham:
I think the correct definition is "One less than the minimum number of items allowed on the last page." -- agreed?
Hi Tim!
Much better, but it's still confusing. In the future maybe we should consider the possibility of doing something like that:
>>> from django.core.paginator import Paginator >>> objects = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'] >>> p = Paginator(objects, 3, min_orphans=2) >>> page2 = p.page(2) >>> page2.object_list output: ['d', 'e', 'f'] >>> page2.has_next() output: True >>> page3 = p.page(3) >>> page3.object_list output: ['g', 'h']
Optional arguments
min_orphans: The minimum number of items allowed on the last page.
It would be much more obvious. On the other hand, I know it implies breaking backwards compatibility. Just and idea.
Thanks.
comment:3 by , 8 years ago
Has patch: | set |
---|
Yes, it's probably better to remove that sentence entirely. I don't think changing the behavior is worth breaking backwards compatibility.
I think the correct definition is "One less than the minimum number of items allowed on the last page." -- agreed?