3π
β
If you are wanting to build the query as X = Y OR W = Z itβs because of
query_kwargs["{0}__{1}".format(field, search_type)] = term
Youβre adding more keys to query_kwargs
with each iteration of the loop rather than re-creating the variable
Would suggest something like this
for field, search_type in self.searchable_fields:
query_q |= Q(**{"{0}__{1}".format(field, search_type): term})
π€justcompile
Source:stackexchange.com