Tag Archives: DRF uses paging function Error

DRF uses paging function Error: unorderedobjectlistwarning

UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: <class ‘myapp.models.Power’> QuerySet.
paginator = self.django_paginator_class(queryset, page_size)

The reason is that you are not sorting.

Solution.
(a) add ordering to the design of the model

class test(models.Model):
    ...

    class Meta:
        ...
        ordering=["xx"]

(b) Add order_by to the query set for sorting