Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

In LimitOffsetPaginationlimit=0 should revert to default limit.#4194

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
lovelydinosaur merged 1 commit intomasterfromlimit-zero-pagination-fix
Jun 13, 2016

Conversation

@lovelydinosaur
Copy link
Contributor

Treatlimit=0 in the same way as an other invalid amount in thelimit` parameter.

@lovelydinosaur
Copy link
ContributorAuthor

Closes#3990.
Closes#3444.

Not that this also removes a now defunct test, that it would return empty results. (Which didn't cover the DivideByZero that it also causes elsewhere.)

@lovelydinosaurlovelydinosaur changed the titlelimit=0 should revert to default limit.In LimitOffsetPaginationlimit=0 should revert to default limit.Jun 13, 2016
@lovelydinosaur
Copy link
ContributorAuthor

Thanks to@mitar and@nhorelik for the input on this! 😄

@lovelydinosaurlovelydinosaur merged commit2e7fae7 intomasterJun 13, 2016
@lovelydinosaurlovelydinosaur deleted the limit-zero-pagination-fix branchJune 13, 2016 15:32
@mitar
Copy link
Contributor

Hm, but with this change it is not possible to ask for maximum allowed number of requests? Client has to know how much is that.

@lovelydinosaur
Copy link
ContributorAuthor

I don't think0==max is particularly intuitive behavior. If someone wants that, then sure override the class and use your own desired behavior. Treating0 the same as any other invalid value seems a pretty reasonable default.

@kevin-brown
Copy link
Contributor

Hm, but with this change it is not possible to ask for maximum allowed number of requests?

There's a note in the docs about how you might go about doing this.

http://www.django-rest-framework.org/api-guide/pagination/#drf-extensions

TheDRF-extensions package includes aPaginateByMaxMixin mixin class that allows your API clients to specify?page_size=max to obtain the maximum allowed page size.

@mitar
Copy link
Contributor

Hm, what is difference betweenmax_limit andmax_page_size?

@mitar
Copy link
Contributor

So it seems that that extension works only when you have pagination, not when you have offset/limit approach. But maybe a similar mixin can be make for offset/limit as well.

helgi added a commit to helgi/workflow-e2e that referenced this pull requestJul 24, 2016
helgi added a commit to helgi/workflow-e2e that referenced this pull requestJul 24, 2016
@stschindler
Copy link

stschindler commentedAug 1, 2017
edited
Loading

Unfortunately this prevents my frontend client to get the count of a particular resource. What I've been doing is sending aGET request to/resource?limit=0 to fetch the total amount of existing records.

Is there any other good way of doing that?

@yli-cpr
Copy link

This breaks old behavior. Clients may have been using ?limit=0 to count objects. Is there any benefit of treating zero as invalid input?

@carltongibson
Copy link
Collaborator

...old behaviour...

That's quite old 😀 v3.4 was mid-2016.

A work around would be to subclassLimitOffsetPagination to check for0 inget_limit before callingsuper.

@yli-cpr
Copy link

yli-cpr commentedJan 15, 2018
edited
Loading

Thanks. I am doing a similar workaround.

@crazy-canux
Copy link

How did you guys fix this?
I upgrade from 3.3 to 3.8, but frontend use &limit=0 not working.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

Projects

None yet

Milestone

3.4.0 Release

Development

Successfully merging this pull request may close these issues.

7 participants

@lovelydinosaur@mitar@kevin-brown@stschindler@yli-cpr@carltongibson@crazy-canux

[8]ページ先頭

©2009-2025 Movatter.jp