Re: [Django] #28032: Abstract away pagination boilerplate

2017-04-06 Thread Django
#28032: Abstract away pagination boilerplate
-+-
 Reporter:  Ian Foote|Owner:  nobody
 Type:   |   Status:  new
  Cleanup/optimization   |
Component:  Core (Other) |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:  Pagination   | Triage Stage:
  Paginator  |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Description changed by Ian Foote:

Old description:

> In the [https://docs.djangoproject.com/en/1.11/topics/pagination/#using-
> paginator-in-a-view documentation for pagination], we recommend using
> this boilerplate:
>

> {{{
>  try:
> contacts = paginator.page(page)
> except PageNotAnInteger:
> # If page is not an integer, deliver first page.
> contacts = paginator.page(1)
> except EmptyPage:
> # If page is out of range (e.g. ), deliver last page of
> results.
> contacts = paginator.page(paginator.num_pages)
> }}}
>
> This could be abstracted away into a simple method on the
> [https://github.com/django/django/blob/5a6f70b4281817656db2f36c5919036d38fcce7f/django/core/paginator.py#L25
> Paginator] class, perhaps named something like {{{results_for_page}}}.

New description:

 In the [https://docs.djangoproject.com/en/1.11/topics/pagination/#using-
 paginator-in-a-view documentation for pagination], we recommend using this
 boilerplate:


 {{{
 try:
 contacts = paginator.page(page)
 except PageNotAnInteger:
 # If page is not an integer, deliver first page.
 contacts = paginator.page(1)
 except EmptyPage:
 # If page is out of range (e.g. ), deliver last page of results.
 contacts = paginator.page(paginator.num_pages)
 }}}

 This could be abstracted away into a simple method on the
 
[https://github.com/django/django/blob/5a6f70b4281817656db2f36c5919036d38fcce7f/django/core/paginator.py#L25
 Paginator] class, perhaps named something like {{{results_for_page}}}.

--

--
Ticket URL: 
Django 
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.24ff591bfb97e045d3f5cd0b9d25a507%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28032: Abstract away pagination boilerplate

2017-04-06 Thread Django
#28032: Abstract away pagination boilerplate
-+-
 Reporter:  Ian Foote|Owner:  nobody
 Type:   |   Status:  new
  Cleanup/optimization   |
Component:  Core (Other) |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:  Pagination   | Triage Stage:
  Paginator  |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Description changed by Ian Foote:

Old description:

> In the [https://docs.djangoproject.com/en/1.11/topics/pagination/#using-
> paginator-in-a-view documentation for pagination], we recommend using
> this boilerplate:
>

> {{{
>  try:
> contacts = paginator.page(page)
> except PageNotAnInteger:
> # If page is not an integer, deliver first page.
> contacts = paginator.page(1)
> except EmptyPage:
> # If page is out of range (e.g. ), deliver last page of
> results.
> contacts = paginator.page(paginator.num_pages)
> }}}
>
> This could be abstracted away into a simple method on the
> [https://github.com/django/django/blob/5a6f70b4281817656db2f36c5919036d38fcce7f/django/core/paginator.py#L25
> {{{Paginator}}}] class, perhaps named something like
> {{{results_for_page}}}.

New description:

 In the [https://docs.djangoproject.com/en/1.11/topics/pagination/#using-
 paginator-in-a-view documentation for pagination], we recommend using this
 boilerplate:


 {{{
  try:
 contacts = paginator.page(page)
 except PageNotAnInteger:
 # If page is not an integer, deliver first page.
 contacts = paginator.page(1)
 except EmptyPage:
 # If page is out of range (e.g. ), deliver last page of
 results.
 contacts = paginator.page(paginator.num_pages)
 }}}

 This could be abstracted away into a simple method on the
 
[https://github.com/django/django/blob/5a6f70b4281817656db2f36c5919036d38fcce7f/django/core/paginator.py#L25
 Paginator] class, perhaps named something like {{{results_for_page}}}.

--

--
Ticket URL: 
Django 
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.d391cf37300583837e71caf57fd9f610%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


[Django] #28032: Abstract away pagination boilerplate

2017-04-06 Thread Django
#28032: Abstract away pagination boilerplate
-+-
   Reporter:  Ian Foote  |  Owner:  nobody
   Type: | Status:  new
  Cleanup/optimization   |
  Component:  Core   |Version:  master
  (Other)|   Keywords:  Pagination
   Severity:  Normal |  Paginator
   Triage Stage: |  Has patch:  0
  Unreviewed |
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  1
  UI/UX:  0  |
-+-
 In the [https://docs.djangoproject.com/en/1.11/topics/pagination/#using-
 paginator-in-a-view documentation for pagination], we recommend using this
 boilerplate:


 {{{
  try:
 contacts = paginator.page(page)
 except PageNotAnInteger:
 # If page is not an integer, deliver first page.
 contacts = paginator.page(1)
 except EmptyPage:
 # If page is out of range (e.g. ), deliver last page of
 results.
 contacts = paginator.page(paginator.num_pages)
 }}}

 This could be abstracted away into a simple method on the
 
[https://github.com/django/django/blob/5a6f70b4281817656db2f36c5919036d38fcce7f/django/core/paginator.py#L25
 {{{Paginator}}}] class, perhaps named something like
 {{{results_for_page}}}.

--
Ticket URL: 
Django 
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.ee366dba9f3aaec0c43157c4894e722b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


<    1   2