tastypie no limit as default behavior
Asked Answered
F

2

9

There's a possibility to append ?limit=0 phrase at the end of the API URL to make the query not limit the response. Is there any way to mae it a default behavior, e.g. http://my.api.com/resources/ (without ?limit=0) will return all resources?

Forte answered 14/8, 2013 at 21:24 Comment(0)
E
15

As the documentation shows, you can use the limit variable in the resource's Meta class:

class FooResource(ModelResource):
    class Meta:
        limit = 0

Or you can set it for all models with the global settings variable API_LIMIT_PER_PAGE.

Eucken answered 14/8, 2013 at 21:51 Comment(4)
Thi is strange, because setting API_LIMIT_PER_PAGE = 0 results in limit set to 1000. So I guess there's an unbreakable limit not to make django process suffocate. Anyway, thanks!Forte
That is odd! Does the same happen if you set limit to 0 on the resource individually?Eucken
It's capped by max_limit; see Jonya Murabe's answer.Dillon
found jonya's answer to work. i did not try without max_limitFiligree
W
14
class FooResource(ModelResource):
    class Meta:
        limit = 0
        max_limit = 0
Whatnot answered 28/8, 2013 at 1:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.