photocrowd / django-cursor-pagination

Cursor-based pagination for Django
BSD 3-Clause "New" or "Revised" License
158 stars 27 forks source link

Populate has_previous and has_next for forward and backwards #16

Closed moggers87 closed 5 years ago

moggers87 commented 6 years ago

This change populates the has_previous and has_next attributes of CursorPage. Inspired by DRF's CursorPagination.

It's not very smart as it assumes if before or after have been set it's not on the first or last page for forward and backward pagination respectively. Personally, I think this is enough.

I have updated tests and I don't think there is a need for any more as everything I changed was fairly well covered to begin with.

mjtamlyn commented 6 years ago

Reading the most up to date version of the spec, it looks like the behaviour of this is now defined as "if you want to". This approach will give sensible results most of the time, so long as you're using a cursor which actually refers to an object.

I think it's a reasonable change, but the behaviour should be documented under Caveats in the readme

moggers87 commented 6 years ago

Updated the caveats section of the README.

Drarok commented 5 years ago

Thank you 👍🏼