Joh*_*ohn 13 django django-rest-framework
在Django Rest Framework 2.x中,您可以访问序列化程序中的"fields"查询参数,例如:
fields = self.context['request'].QUERY_PARAMS.get('fields')
Run Code Online (Sandbox Code Playgroud)
这在DRF 3.0中不再有效,但除了一般术语之外,我无法找到API中记录的更改.看起来它可能是类似self.context.get('request')?????但我无法弄明白.
你会如何在DRF 3.0中做到这一点?我说的是在序列化程序中而不是在视图中访问query.params .
谢谢
约翰
Joh*_*ohn 21
这是DRF 3:
fields = self.context.get('request').query_params.get('fields')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7087 次 |
| 最近记录: |