Django pagination is repeating results

I have this weird pagination bug in Django: using object_list as a return of a view, but passing a "paginate_by" argument to it, it's repeating some of the results; Otherwise, if I remove the argument or set as "paginate_by=None", the results are correct.

If using pagination, the quantity of results is maintained at a total, so, because there are repeated results, the last results are left out of the list, so they don't appear in the template.

Any ideas of what might be happening?

Thanks!

Answers


I had this problem also, but found a solution.

The problem was that i sorted the dataset by date. When i had multiple records with the same date, pagination showed wrong records.

What i did was i added another searchfield, id, so that the sortcriteria was unique for every record. And then it worked!

Before:

self.filtered_nesgames = self.filtered_nesgames.order_by('releasedate')

After:

self.filtered_nesgames = self.filtered_nesgames.order_by('releasedate', 'id')

HTH


Aparently there's an open issue about documenting how pagination works with django-filter.

Try following the advice given by the issue submitter, bartTC.


Need Your Help

Using Moq to override virtual methods in the same class

c# unit-testing moq

We are using Moq to unit test our service classes, but are stuck on how to test situations where a service method calls another service method of the same class. I tried setting the method being c...

Creating Thumbnail for Video in iOS

ios objective-c thumbnails video-thumbnails

I have an application that I am developing for the iPhone. What it does is, it captures the video from the camera and stores the video file onto the File System.