Django Rest Framework: Dynamically return subset of fields

后端 未结 8 724
南笙
南笙 2020-11-28 18:16

Problem

As recommended in the blogpost Best Practices for Designing a Pragmatic RESTful API, I would like to add a fields query parameter to a Django R

8条回答
  •  忘掉有多难
    2020-11-28 18:58

    Such functionality we've provided in drf_tweaks / control-over-serialized-fields.

    If you use our serializers, all you need is to pass ?fields=x,y,z parameter in the query.

提交回复
热议问题