Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tastypie no limit as default behavior

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?

like image 330
ducin Avatar asked Aug 14 '13 21:08

ducin


2 Answers

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.

like image 157
Ben Avatar answered Sep 28 '22 16:09

Ben


class FooResource(ModelResource):
    class Meta:
        limit = 0
        max_limit = 0
like image 32
Junya Murabe Avatar answered Sep 28 '22 15:09

Junya Murabe