MattBroach / DjangoRestMultipleModels

View (and mixin) for serializing multiple models or querysets in Django Rest Framework
MIT License
549 stars 67 forks source link

Pagination question #39

Closed iamanikeev closed 6 years ago

iamanikeev commented 6 years ago

Hi @MattBroach ! I was trying to implement PageNumberPagination support, and it seems to me at this point that for flat views it's better to paginate the whole data, instead of paginating each queryset separately. First I was trying to make some kind of distribution, i.e. if page size is set to 10 and there are 2 querysets, paginate each of them by 5. But this has quite a lot of flaws. For instance, if one of querysets is empty, this just reduces result amount by the portion of data that queryset was supposed to occupy. I saw from the doc, that previous version used to paginate over the whole data set, can you clarify why this was changed? Also, how about different types of pagination for Flat/Object views?

iamanikeev commented 6 years ago

Oh wait, I think I got this :) It gets terribly slow this way)

MattBroach commented 6 years ago

Haha, I was literally in the middle of posting my reply to that effect when you wrote that. If you want to read more on the issue, here's a response I wrote to a similar issue: all responses pagination.

For the record, I don't have any objection to different kinds of pagination for Flat and Object views. But my current opinion is that any pagination, in order to make it into the library, should work at the DB level, not just the API level. But it seems like you already figured that out!