          self.assertEqual(response.data['next'], None)
          self.assertNotEqual(response.data['previous'], None)
  
          request = factory.get(response.data['previous'])
          response = self.view(request).render()
          self.assertEqual(response.status_code, status.HTTP_200_OK)
          self.assertEqual(response.data['count'], 15)
          self.assertEqual(response.data['results'], self.data[:10])
          self.assertNotEqual(response.data['next'], None)
          self.assertEqual(response.data['previous'], None)
 
</s> remove         response = self.view(request).render()
 </s> add         with self.assertNumQueries(EXPECTED_NUM_QUERIES):
            response = view(request).render() </s> remove         response = self.view(request).render()
 </s> add         with self.assertNumQueries(EXPECTED_NUM_QUERIES):
            response = view(request).render() </s> remove if django_filters:
    class DecimalFilter(django_filters.FilterSet):
        decimal = django_filters.NumberFilter(lookup_type='lt')

        class Meta:
            model = FilterableItem
            fields = ['text', 'decimal', 'date']

    class FilterFieldsRootView(generics.ListCreateAPIView):
        model = FilterableItem
        paginate_by = 10
        filter_class = DecimalFilter
        filter_backend = filters.DjangoFilterBackend


 </s> add  </s> remove        -egit+git://github.com/alex/django-filter.git#egg=django_filter
 </s> add        django-filter==0.6a1 </s> remove        -egit+git://github.com/alex/django-filter.git#egg=django_filter
 </s> add        django-filter==0.6a1
        with self.assertNumQueries(EXPECTED_NUM_QUERIES):
            response = view(request).render()
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['count'], 15)
        self.assertEqual(response.data['results'], self.data[:10])
        self.assertNotEqual(response.data['next'], None)
        self.assertEqual(response.data['previous'], None)

    def test_get_basic_paginated_filtered_root_view(self):
        """
        Same as `test_get_django_filter_paginated_filtered_root_view`,
        except using a custom filter backend instead of the django-filter
        backend,
        """

        class DecimalFilterBackend(filters.BaseFilterBackend):
            def filter_queryset(self, request, queryset, view):
                return queryset.filter(decimal__lt=Decimal(request.GET['decimal']))

        class BasicFilterFieldsRootView(generics.ListCreateAPIView):
            model = FilterableItem
            paginate_by = 10
            filter_backend = DecimalFilterBackend

        view = BasicFilterFieldsRootView.as_view()

        request = factory.get('/?decimal=15.20')
        with self.assertNumQueries(2):
            response = view(request).render()
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['count'], 15)
        self.assertEqual(response.data['results'], self.data[:10])
        self.assertNotEqual(response.data['next'], None)
        self.assertEqual(response.data['previous'], None)

        request = factory.get(response.data['next'])
        with self.assertNumQueries(2):
            response = view(request).render()
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['count'], 15)
        self.assertEqual(response.data['results'], self.data[10:15])
        self.assertEqual(response.data['next'], None)
        self.assertNotEqual(response.data['previous'], None)

        request = factory.get(response.data['previous'])
        with self.assertNumQueries(2):
            response = view(request).render()
          self.assertEqual(response.data['next'], None)
          self.assertNotEqual(response.data['previous'], None)
  
          request = factory.get(response.data['previous'])
        with self.assertNumQueries(EXPECTED_NUM_QUERIES):
            response = view(request).render()
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['count'], 15)
        self.assertEqual(response.data['results'], self.data[:10])
        self.assertNotEqual(response.data['next'], None)
        self.assertEqual(response.data['previous'], None)

    def test_get_basic_paginated_filtered_root_view(self):
        """
        Same as `test_get_django_filter_paginated_filtered_root_view`,
        except using a custom filter backend instead of the django-filter
        backend,
        """

        class DecimalFilterBackend(filters.BaseFilterBackend):
            def filter_queryset(self, request, queryset, view):
                return queryset.filter(decimal__lt=Decimal(request.GET['decimal']))

        class BasicFilterFieldsRootView(generics.ListCreateAPIView):
            model = FilterableItem
            paginate_by = 10
            filter_backend = DecimalFilterBackend

        view = BasicFilterFieldsRootView.as_view()

        request = factory.get('/?decimal=15.20')
        with self.assertNumQueries(2):
            response = view(request).render()
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['count'], 15)
        self.assertEqual(response.data['results'], self.data[:10])
        self.assertNotEqual(response.data['next'], None)
        self.assertEqual(response.data['previous'], None)

        request = factory.get(response.data['next'])
        with self.assertNumQueries(2):
            response = view(request).render()
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['count'], 15)
        self.assertEqual(response.data['results'], self.data[10:15])
        self.assertEqual(response.data['next'], None)
        self.assertNotEqual(response.data['previous'], None)

        request = factory.get(response.data['previous'])
        with self.assertNumQueries(2):
            response = view(request).render()
          self.assertEqual(response.status_code, status.HTTP_200_OK)
          self.assertEqual(response.data['count'], 15)
          self.assertEqual(response.data['results'], self.data[:10])
          self.assertNotEqual(response.data['next'], None)
          self.assertEqual(response.data['previous'], None)
keep keep keep keep replace keep keep keep keep keep
 Use django-filter 0.6a1 and add database query count tests for paginated, filtered lists. 
rest_framework/tests/pagination.py