no need to do distinct on every loop cycle & add analogue of distinct for oracle users

This commit is contained in:
tony 2015-05-14 17:04:22 +03:00
parent 7813d2fb35
commit c47ec60ea2

View File

@ -106,9 +106,12 @@ class SearchFilter(BaseFilterBackend):
or_queries = [models.Q(**{orm_lookup: search_term})
for orm_lookup in orm_lookups]
queryset = queryset.filter(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":
queryset = queryset.distinct()
else:
pk_list = queryset.values_list('pk', flat=True)
queryset = view.model.objects.filter(pk__in=set(pk_list))
return queryset