0
我有一个分页结果集,所以响应返回这样的:Django的REST框架:添加自定义字段为分页视图集中
{
"count": 944,
"next": "http://api.visitorlando.teeny/consumer/listings/?page=3",
"previous": "http://api.visitorlando.teeny/consumer/listings/",
"results": [
{...}]
}
我需要另一个自定义字段添加到这样的回应:
{
"count": 944,
"custom_field": "test",
"next": "http://api.visitorlando.teeny/consumer/listings/?page=3",
"previous": "http://api.visitorlando.teeny/consumer/listings/",
"results": [
{...}]
}
而我在ViewSet中。我怎么能做到这一点?
你可以在这里找到解决方案。 http://www.django-rest-framework.org/api-guide/pagination/#custom-pagination-styles – Devansh