diff options
| author | Tom Christie | 2015-01-14 17:46:41 +0000 |
|---|---|---|
| committer | Tom Christie | 2015-01-14 17:46:41 +0000 |
| commit | 313aa727e3c44016e531a7af75051fc6e6d7cb96 (patch) | |
| tree | 95dd1fa7eed81fc716daafdf7477b1671879c621 /rest_framework/pagination.py | |
| parent | 3833a5bb8a9174e5fb09dac59a964eff24b6065e (diff) | |
| download | django-rest-framework-313aa727e3c44016e531a7af75051fc6e6d7cb96.tar.bz2 | |
Tweaks
Diffstat (limited to 'rest_framework/pagination.py')
| -rw-r--r-- | rest_framework/pagination.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/rest_framework/pagination.py b/rest_framework/pagination.py index bd343c0d..69d0f77d 100644 --- a/rest_framework/pagination.py +++ b/rest_framework/pagination.py @@ -46,6 +46,12 @@ def _get_displayed_page_numbers(current, final): For example: current=14, final=16 -> [1, None, 13, 14, 15, 16] + + This implementation gives one page to each side of the cursor, + for an implementation which gives two pages to each side of the cursor, + which is a copy of how GitHub treat pagination in their issue lists, see: + + https://gist.github.com/tomchristie/321140cebb1c4a558b15 """ assert current >= 1 assert final >= current @@ -60,10 +66,12 @@ def _get_displayed_page_numbers(current, final): # If the break would only exclude a single page number then we # may as well include the page number instead of the break. - if current == 4: + if current <= 4: included.add(2) - if current == final - 3: + included.add(3) + if current >= final - 3: included.add(final - 1) + included.add(final - 2) # Now sort the page numbers and drop anything outside the limits. included = [ |
