-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support pagination natively #78
Comments
I think it's better to write your own paginate mixin. |
@seocam nice approach, just a note: there's not need to use
since the django Paginator class will take care of bad page numbers, so your code can be even shorter:
https://github.com/django/django/blob/master/django/core/paginator.py#L52 |
Just add a little note: def serialize_list(self, data):
if getattr(self, 'paginate', False):
page_size = getattr(self, 'page_size', DEFAULT_RESULTS_PER_PAGE)
paginator = Paginator(data.value, page_size) # get value data
page_number = self.request.GET.get('p', 1)
self.page = paginator.page(page_number) # This django method takes care of the page number
data = self.page.object_list
return super().serialize_list(data) https://docs.djangoproject.com/en/1.10/topics/pagination/#example If you got error |
@seocam just wondering if you had any plans on submitting a PR for this feature? Thanks! |
Hey @CalebeGeazi. Honestly I had forgot that this issue was open. Thanks for bumping it up. @toastdriven do you have any thoughts about that? If you don't oppose I think it's time to add a few extra features here ;) |
I've merged #114 witch adds pagination for Django. @Marcelo-Theodoro could you create a new PR that actually adds the pagination independent of framework? Thanks! |
Guys, do you think that the pagination should be enabled or disabled by default? |
I think we could turn it on or off depending on the |
What do you guys think about native support to pagination? We could implement that using Django paginator (for example) since it doesn't have external dependencies.
That's helpful in most listing APIs. Here is just an example on how it could be implemented in the Resource:
And to use simply add to your resource:
If that seems useful I'm willing to create a PR with tests and docs.
The text was updated successfully, but these errors were encountered: