[英]How to change DRF to use a Response from a schema?
Is it possible to change the Django Rest Framework to use a Response from a schema? 是否可以更改Django Rest框架以使用来自模式的响应?
For example, a GET using the standard DRF will output: 例如,使用标准DRF的GET将输出:
{
"count": 0,
"next": null,
"previous": null,
"results": []
}
Where I would like it to output 我想输出到哪里
{
"meta_stuff": {
"License": "MIT"
},
"data": []
}
Where results
= data
and an extra
). results
= data
和extra
)。 Would I need to customise DRF or can a swagger.JSON schema be used to achieve this? 我需要自定义DRF还是可以使用swagger.JSON模式来实现此目的?
I suppose you're talking about pagination style. 我想您正在谈论分页样式。 If so you should look at this link: http://www.django-rest-framework.org/api-guide/pagination/#custom-pagination-styles .
如果是这样,您应该查看以下链接: http : //www.django-rest-framework.org/api-guide/pagination/#custom-pagination-styles 。
Basically you're going to write your own custom Pagination class, customizing DRF's behavior. 基本上,您将编写自己的自定义分页类,以自定义DRF的行为。 Documentation's example is exactly what you've described.
文档的示例正是您所描述的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.