#NEWLINE# def quick_search_filter( model , search_text , prefix = '' ) : #NEWLINE# #INDENT# q = models . Q ( ) #NEWLINE# for fn in model . quick_search_fields : #NEWLINE# #INDENT# kw = { #NEWLINE# #INDENT# ( ( prefix + fn ) + '__icontains' ) : search_text , #NEWLINE# #UNINDENT# } #NEWLINE# q = ( q | models . Q ( ** kw ) ) #NEWLINE# #UNINDENT# if search_text . isdigit ( ) : #NEWLINE# #INDENT# for field in model . _meta . fields : #NEWLINE# #INDENT# if isinstance ( field , ( models . IntegerField , models . AutoField ) ) : #NEWLINE# #INDENT# kw = { #NEWLINE# #INDENT# ( prefix + field . name ) : int ( search_text ) , #NEWLINE# #UNINDENT# } #NEWLINE# q = ( q | models . Q ( ** kw ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return q