for filter_url_parameter in dynamic_queries splitted_url_paramet er fi

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
for filter_url_parameters in dynamic_queries:
splitted_url_parameter = filter_url_parameters.split('||')
filters_by_id = defaultdict(list)
if len(splitted_url_parameter) == 4:
filter_id, lookup_type, filter_value, is_negated = splitted_url_parameter
try:
filter_ = Filter.objects.get(pk=filter_id)
stored_filter = StoredQueryFilter(filter=filter_, lookup=lookup_type, value=filter_value,
is_not=is_negated)
filters_by_id[filter_id].append(stored_filter)
except (Filter.DoesNotExist, ValueError):
pass
haystack_query = SQ()
for stored_filters in filters_by_id.values():
query = self._build_query(haystack_query, stored_filters)
queryset = queryset.filter(pk__in=self._get_pk_list(haystack_query, queryset.model))