Django API list with pagination - Page is not JSON serializable

后端 未结 2 760
情书的邮戳
情书的邮戳 2021-01-14 13:08

I am trying to create a Django API for a list with pagination but have this error

TypeError: Object of type \'Page\' is not JSON serializable
2条回答
  •  情话喂你
    2021-01-14 13:36

    If anyone using Django Rest Framework (DRF) finds this, DRF serializers can serialize page.object_list to JSON. Of course, the better way is to specify pagination_class in DRF view(set)s: https://www.django-rest-framework.org/api-guide/pagination/

提交回复
热议问题