dynamic_query request GET getlist dynamic_query if dynamic_query filte

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
dynamic_query = request.GET.getlist('dynamic_query')
if dynamic_query:
filters_map = {}
for q in dynamic_query:
qlist = q.split('||')
filters_map[qlist[0]] = filters_map.get(qlist[0], []) + [StoredQueryFilter(filter=Filter.objects.get(pk=qlist[0]), lookup=qlist[1], value=qlist[2], is_not=str2bool(qlist[3]))]#group by filter key
query = SQ()
for values in filters_map.values():
query = self._build_query(query, values)
queryset = queryset.filter(pk__in=self._get_pk_list(query, queryset.model))