2016-05-15 79 views
-1

在我的詳細信息視圖我已經followig結果如何篩選Django rest框架中的嵌套數據?

{ // 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過濾數據e.g 20 <值到dispay如何實現的呢?

查看:

class MeasuresList(viewsets.ModelViewSet): 
    serializer_class = serializers.DetailedMeasureSerializer 

    def get_queryset(self): 
     return Measure.objects.all() 

回答

0

過濾它,當你從數據庫中

def get_queryset(self): 
    return Measure.objects.filter(averages__value__range=(20.0, 30.0)) 
+0

我需要過濾averaves閱讀它 - 嵌套的測量對象 –

相關問題