mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-23 01:57:00 +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))
|
||||
for search_field in search_fields]
|
||||
|
||||
and_queries = []
|
||||
for search_term in self.get_search_terms(request):
|
||||
or_queries = [models.Q(**{orm_lookup: search_term})
|
||||
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":
|
||||
queryset = queryset.distinct()
|
||||
if settings.DATABASES[queryset.db]["ENGINE"] == "django.db.backends.oracle":
|
||||
pk_list = queryset.filter(reduce(operator.and_, and_queries)).values_list('pk', flat=True)
|
||||
return queryset.filter(pk__in=frozenset(pk_list))
|
||||
else:
|
||||
pk_list = queryset.values_list('pk', flat=True)
|
||||
queryset = view.model.objects.filter(pk__in=set(pk_list))
|
||||
return queryset
|
||||
return queryset.filter(reduce(operator.and_, and_queries)).distinct()
|
||||
|
||||
|
||||
class OrderingFilter(BaseFilterBackend):
|
||||
|
|
Loading…
Reference in New Issue
Block a user