mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-27 03:54:01 +03:00
removed using view.model.objects
This commit is contained in:
parent
c47ec60ea2
commit
de95598a1e
|
@ -101,18 +101,17 @@ class SearchFilter(BaseFilterBackend):
|
||||||
|
|
||||||
orm_lookups = [self.construct_search(six.text_type(search_field))
|
orm_lookups = [self.construct_search(six.text_type(search_field))
|
||||||
for search_field in search_fields]
|
for search_field in search_fields]
|
||||||
|
and_queries = []
|
||||||
for search_term in self.get_search_terms(request):
|
for search_term in self.get_search_terms(request):
|
||||||
or_queries = [models.Q(**{orm_lookup: search_term})
|
or_queries = [models.Q(**{orm_lookup: search_term})
|
||||||
for orm_lookup in orm_lookups]
|
for orm_lookup in orm_lookups]
|
||||||
queryset = queryset.filter(reduce(operator.or_, or_queries))
|
and_queries.append(reduce(operator.or_, or_queries))
|
||||||
|
|
||||||
if settings.DATABASES[queryset.db]["ENGINE"] != "django.db.backends.oracle":
|
if settings.DATABASES[queryset.db]["ENGINE"] == "django.db.backends.oracle":
|
||||||
queryset = queryset.distinct()
|
pk_list = queryset.filter(reduce(operator.and_, and_queries)).values_list('pk', flat=True)
|
||||||
|
return queryset.filter(pk__in=frozenset(pk_list))
|
||||||
else:
|
else:
|
||||||
pk_list = queryset.values_list('pk', flat=True)
|
return queryset.filter(reduce(operator.and_, and_queries)).distinct()
|
||||||
queryset = view.model.objects.filter(pk__in=set(pk_list))
|
|
||||||
return queryset
|
|
||||||
|
|
||||||
|
|
||||||
class OrderingFilter(BaseFilterBackend):
|
class OrderingFilter(BaseFilterBackend):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user