因此,通过@limelights,我设法完成了我想要的工作,这是代码:
class PassengerList(generics.ListCreateAPIView): model = Passenger serializer_class = PassengerSerializer # Show all of the PASSENGERS in particular WORKSPACE # or all of the PASSENGERS in particular AIRLINE def get_queryset(self): queryset = Passenger.objects.all() workspace = self.request.query_params.get('workspace') airline = self.request.query_params.get('airline') if workspace: queryset = queryset.filter(workspace_id=workspace) elif airline: queryset = queryset.filter(workspace__airline_id=airline) return queryset
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)