Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable pagination in Django tastypie?

I have a tastypie api that I'm working on and in the list views for my api resources I'd like to get the entire list of data without pagination applied, regardless of the number of objects in the list. I don't need a custom paginator with a high limit, I'd like to disable pagination entirely.

I could potentially modify my client to deal with the pagination (the api is being accessed from a C++ DLL rather than a web browser so it's a little more complicated but possible) but if I can disable it that would be easier.

Is there a switch to disable the paginator for different resources, or possibly an api wide switch to disable pagination on all resources registered to that api object?

like image 663
Alex Avatar asked Apr 03 '13 18:04

Alex


1 Answers

To do this you need to set at least two different things.

In the site settings file, set

API_LIMIT_PER_PAGE = 0

In the resource Meta class that you want to disable pagination for, set:

class MyResource(ModelResource):
    ...
    class Meta:
        ...
        max_limit = None

Then if you navigate to the list view of the resource, the returned content should show a limit of 0.

like image 135
Alex Avatar answered Oct 03 '22 20:10

Alex