在我的详细视图中,我有以下结果
{ // measure object
"id": 5,
"name": "co",
"averages": [ // list of averages
{
"start": "2016-05-15T12:18:15Z",
"end": "2016-05-15T12:18:16Z",
"value": 22.0,
"length": 4
}
]
}
我需要在averages
过滤的数据中显示,例如20<价值< 30。
怎么实现呢?
查看:
class MeasuresList(viewsets.ModelViewSet):
serializer_class = serializers.DetailedMeasureSerializer
def get_queryset(self):
return Measure.objects.all()
答案 0 :(得分:0)
从数据库中读取时过滤它
def get_queryset(self):
return Measure.objects.filter(averages__value__range=(20.0, 30.0))