<s> from django . contrib . admin . views . main import * <EOL> from django . contrib . admin import ModelAdmin <EOL> from djangosphinx . models import SphinxQuerySet <EOL> class SphinxModelAdmin ( ModelAdmin ) : <EOL> index = None <EOL> weights = None <EOL> search_fields = [ '<STR_LIT>' ] <EOL> actions = None <EOL> def queryset ( self , request ) : <EOL> return SphinxQuerySet ( <EOL> model = self . model , <EOL> index = self . index , <EOL> ) <EOL> def get_changelist ( self , request , ** kwargs ) : <EOL> return SphinxChangeList <EOL> class SphinxChangeList ( ChangeList ) : <EOL> def get_query_set ( self ) : <EOL> qs = self . root_query_set <EOL> lookup_params = self . params . copy ( ) <EOL> for i in ( ALL_VAR , ORDER_VAR , ORDER_TYPE_VAR , SEARCH_VAR , IS_POPUP_VAR ) : <EOL> if i in lookup_params : <EOL> del lookup_params [ i ] <EOL> for key , value in lookup_params . items ( ) : <EOL> if not isinstance ( key , str ) : <EOL> del lookup_params [ key ] <EOL> lookup_params [ smart_str ( key ) ] = value <EOL> if key . endswith ( '<STR_LIT>' ) : <EOL> lookup_params [ key ] = value . split ( '<STR_LIT:U+002C>' ) <EOL> try : <EOL> qs = qs . filter ( ** lookup_params ) <EOL> except : <EOL> raise IncorrectLookupParameters <EOL> if not qs . _select_related : <EOL> if self . list_select_related : <EOL> qs = qs . select_related ( ) <EOL> else : <EOL> for field_name in self . list_display : <EOL> try : <EOL> f = self . lookup_opts . get_field ( field_name ) <EOL> except models . FieldDoesNotExist : <EOL> pass <EOL> else : <EOL> if isinstance ( f . rel , models . ManyToOneRel ) : <EOL> qs = qs . select_related ( ) <EOL> break <EOL> if self . order_field : <EOL> qs = qs . order_by ( '<STR_LIT>' % ( ( self . order_type == '<STR_LIT>' and '<STR_LIT:->' or '<STR_LIT>' ) , self . order_field ) ) <EOL> if self . query : <EOL> qs = qs . query ( self . query ) <EOL> if not ( lookup_params or self . query ) : <EOL> return qs . none ( ) <EOL> return qs <EOL> def get_results ( self , request ) : <EOL> paginator = Paginator ( self . query_set , self . list_per_page ) <EOL> result_count = paginator . count <EOL> multi_page = result_count > self . list_per_page <EOL> try : <EOL> result_list = paginator . page ( self . page_num + <NUM_LIT:1> ) . object_list <EOL> except InvalidPage : <EOL> result_list = ( ) <EOL> self . full_result_count = result_count <EOL> self . result_count = result_count <EOL> self . result_list = result_list <EOL> self . can_show_all = False <EOL> self . multi_page = multi_page <EOL> self . paginator = paginator </s>
