#35452: There seems to an issue with the doc on django's orphans and its
implementation
-------------------------------------+-------------------------------------
     Reporter:  Strapchay            |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  Core (Other)         |                  Version:  dev
     Severity:  Normal               |               Resolution:
     Keywords:  pagination,          |             Triage Stage:  Accepted
  paginator                          |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):

 * stage:  Unreviewed => Accepted
 * type:  Bug => Cleanup/optimization
 * version:  5.0 => dev

Comment:

 Hello Strapchay, thank you for your report.

 My initial thinking about this report is that having an `orphans` value
 bigger than the page size does not make sense. Could you share a valid use
 case for that?

 Having said that, I think this ticket is valid in that the code should
 either:
 1. enforce that `orphans` is strictly smaller than the page size
 (`per_page`), or
 2. explicitly document that if `orphans` is equal or higher than
 `per_page`, you'll get unexpected results.

 Reproducers:
 {{{
 >>> from django.core.paginator import Paginator
 >>> p = Paginator([str(i) for i in range(9)], per_page=2, orphans=3)
 >>> for i in range(p.num_pages): print(p.page(i+1).object_list)
 ...
 ['0', '1']
 ['2', '3']
 ['4', '5', '6', '7', '8']
 >>>

 >>> p = Paginator([str(i) for i in range(9)], per_page=2, orphans=5)
 >>> for i in range(p.num_pages): print(p.page(i+1).object_list)
 ...
 ['0', '1']
 ['2', '3', '4', '5', '6', '7', '8']

 >>> p = Paginator([str(i) for i in range(9)], per_page=3, orphans=3)
 >>> for i in range(p.num_pages): print(p.page(i+1).object_list)
 ...
 ['0', '1', '2']
 ['3', '4', '5', '6', '7', '8']
 }}}

 I'm inclined to do option 1 but we'd need to do it with a deprecation path
 in case there are code bases out there misusing the `orphans` value.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35452#comment:1>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018f770c1c38-59923da7-4fc6-4cda-9dc0-1e43a802edd5-000000%40eu-central-1.amazonses.com.

Reply via email to