JSON serialization error in Django Rest Framework when using pagination
<p>I just tried to add pagination using <code>pagination_class = TenItemsSetPagination</code> to my class-based-view.
As a result, I get an error trying to access my endpoint: <code>&lt;Response status_code=200, "text/html; charset=utf-8"&gt; is not JSON serializable</code></p>

<p>views.py:</p>

<pre><code>class AllCartsView(ListModelMixin, generics.GenericAPIView):
    permission_classes = [AllowAny]
    authentication_classes = []
    queryset = Cart.objects.all()

    serializer_class = carts_serializers.DataCartSerializer
    renderer_classes = (BrowsableAPIRenderer, JSONRenderer,)
    pagination_class = TenItemsSetPagination

    def get(self, request, *args, **kwargs):
        return self.list(request, *args, **kwargs)
</code></pre>

<p>paginators.py</p>

<pre><code>class TenItemsSetPagination(PageNumberPagination):
    page_size = 10
</code></pre>

<ul>
<li>Versions : Django 1.9.9 / DRF 3.3</li>
</ul>

<p>Any idea? Thanks.</p>

<p>Just noticed that using <code>(ListModelMixin, generics.GenericAPIView)</code> instead of <code>(ListAPIView)</code> is responsible for the error.</p>

python django django-rest-framework