<s> from django . db import models <EOL> from django . db . models import Q <EOL> class CountrySearchManager ( models . Manager ) : <EOL> def search ( self , ** kwargs ) : <EOL> qs = self . get_query_set ( ) <EOL> query = kwargs . get ( '<STR_LIT:q>' , '<STR_LIT>' ) <EOL> government = kwargs . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> if government : <EOL> qs = qs . filter ( government_type = government ) <EOL> if query : <EOL> qs = qs . filter ( Q ( Q ( name__icontains = query ) | <EOL> Q ( background__icontains = query ) ) ) <EOL> return qs </s>
