def get_queryset(self): if self.dataset: queryset = self.dataset.record_queryset search_param = self.request.query_params.get('search') if search_param is not None: field_info = { 'data': self.dataset.schema.field_names, 'source_info': ['file_name', 'row'] } queryset = search_json_fields(queryset, field_info, search_param) ordering_param = self.request.query_params.get('ordering') if ordering_param is not None: queryset = order_by_json_field(queryset, 'data', self.dataset.schema.field_names, ordering_param) queryset = order_by_json_field(queryset, 'source_info', ['file_name', 'row'], ordering_param) return queryset else: return Record.objects.none()
def get_queryset(self): queryset = super(RecordViewSet, self).get_queryset() if self.dataset: # add some specific json field queries (postgres) search_param = self.request.query_params.get('search') if search_param is not None: field_info = { 'data': self.dataset.schema.field_names, 'source_info': ['file_name', 'row'] } queryset = search_json_fields(queryset, field_info, search_param) ordering_param = self.request.query_params.get('ordering') if ordering_param is not None: queryset = order_by_json_field(queryset, 'data', self.dataset.schema.field_names, ordering_param) queryset = order_by_json_field(queryset, 'source_info', ['file_name', 'row'], ordering_param) return queryset