current_techniques.append({'id':project['project_id'],'name':project['project_name']})# Create a new dict INSIDE the list with the project ID and project name.
ifsearch_fieldsisnotNoneandsearch_fields!=""andsearch!=""andsearch_fields!=['None']:# If the searchf ield is not set to None AND search_fields is not empty AND search_fields is not an empty list..
forfieldinsearch_fields:
forfieldinsearch_fields:# For each field in search fields..
substring=project[field]
substring=project[field]# Save the current field in substring so we can do operations on it..
# Check type before calling lower()
# Check types before calling lower()
ifisinstance(substring,str):
ifisinstance(substring,str):
substring=substring.lower()
substring=substring.lower()# Make case insensitive
ifsubstring.find(search)!=-1:
ifsubstring.find(search)!=-1:# If found
search_results.append(project)
search_results.append(project)
break
break
elifisinstance(substring,int):
elifisinstance(substring,int):
ifstr(substring).find(search)!=-1:
ifstr(substring).find(search)!=-1:
search_results.append(project)
search_results.append(project)
break
break
elifisinstance(substring,list):
elifisinstance(substring,list):# If it's a list..
forsubsubstringinsubstring:
forsubsubstringinsubstring:# We'll need to make another substring so we can iterate over each index of the list instead of just for multiple lists.