def get_query(query_string, search_fields):
query = None  <EOL>terms = normalize_query(query_string)<EOL>for term in terms:<EOL><INDENT>or_query = None  <EOL>for field_name in search_fields:<EOL><INDENT>q = Q(**{"<STR_LIT>" % field_name: term})<EOL>if or_query is None:<EOL><INDENT>or_query = q<EOL><DEDENT>else:<EOL><INDENT>or_query = or_query | q<EOL><DEDENT><DEDENT>if query is None:<EOL><INDENT>query = or_query<EOL><DEDENT>else:<EOL><INDENT>query = query & or_query<EOL><DEDENT><DEDENT>if query is None:<EOL><INDENT>query = Q()<EOL><DEDENT>return query<EOL>
Returns a query as a combination of Q objects that query the specified
search fields.