<s> """<STR_LIT>""" <EOL> import itertools <EOL> from django . db import models <EOL> from django . db . models import FieldDoesNotExist <EOL> try : <EOL> from django . db . models . fields . related import RelatedObject <EOL> from django . db . models . fields . related import RelatedField <EOL> NEW_META_API = False <EOL> except ImportError : <EOL> NEW_META_API = True <EOL> try : <EOL> from django . db . models . query import ValuesQuerySet <EOL> from django . db . models . sql . where import Constraint <EOL> NEW_RELATED_API = False <EOL> except ImportError : <EOL> from django . db . models . query import ValuesIterable <EOL> NEW_RELATED_API = True <EOL> from django . utils . six import moves <EOL> from django . utils . tree import Node <EOL> try : <EOL> from django . db . models . lookups import Lookup <EOL> from django . db . models . sql . datastructures import Col <EOL> NEW_LOOKUPS = True <EOL> except ImportError : <EOL> NEW_LOOKUPS = False <EOL> from modeltranslation import settings <EOL> from modeltranslation . fields import TranslationField <EOL> from modeltranslation . utils import ( build_localized_fieldname , get_language , <EOL> auto_populate , resolution_order ) <EOL> def get_translatable_fields_for_model ( model ) : <EOL> from modeltranslation . translator import NotRegistered , translator <EOL> try : <EOL> return translator . get_options_for_model ( model ) . get_field_names ( ) <EOL> except NotRegistered : <EOL> return None <EOL> def rewrite_lookup_key ( model , lookup_key ) : <EOL> pieces = lookup_key . split ( '<STR_LIT>' , <NUM_LIT:1> ) <EOL> original_key = pieces [ <NUM_LIT:0> ] <EOL> translatable_fields = get_translatable_fields_for_model ( model ) <EOL> if translatable_fields is not None : <EOL> if pieces [ <NUM_LIT:0> ] in translatable_fields : <EOL> pieces [ <NUM_LIT:0> ] = build_localized_fieldname ( pieces [ <NUM_LIT:0> ] , get_language ( ) ) <EOL> if len ( pieces ) > <NUM_LIT:1> : <EOL> fields_to_trans_models = get_fields_to_translatable_models ( model ) <EOL> if original_key in fields_to_trans_models : <EOL> transmodel = fields_to_trans_models [ original_key ] <EOL> pieces [ <NUM_LIT:1> ] = rewrite_lookup_key ( transmodel , pieces [ <NUM_LIT:1> ] ) <EOL> return '<STR_LIT>' . join ( pieces ) <EOL> def append_fallback ( model , fields ) : <EOL> """<STR_LIT>""" <EOL> fields = set ( fields ) <EOL> trans = set ( ) <EOL> from modeltranslation . translator import translator <EOL> opts = translator . get_options_for_model ( model ) <EOL> for key , _ in opts . fields . items ( ) : <EOL> if key in fields : <EOL> langs = resolution_order ( get_language ( ) , getattr ( model , key ) . fallback_languages ) <EOL> fields = fields . union ( build_localized_fieldname ( key , lang ) for lang in langs ) <EOL> fields . remove ( key ) <EOL> trans . add ( key ) <EOL> return fields , trans <EOL> def append_translated ( model , fields ) : <EOL> "<STR_LIT>" <EOL> fields = set ( fields ) <EOL> from modeltranslation . translator import translator <EOL> opts = translator . get_options_for_model ( model ) <EOL> for key , translated in opts . fields . items ( ) : <EOL> if key in fields : <EOL> fields = fields . union ( f . name for f in translated ) <EOL> return fields <EOL> def append_lookup_key ( model , lookup_key ) : <EOL> "<STR_LIT>" <EOL> pieces = lookup_key . split ( '<STR_LIT>' , <NUM_LIT:1> ) <EOL> fields = append_translated ( model , ( pieces [ <NUM_LIT:0> ] , ) ) <EOL> if len ( pieces ) > <NUM_LIT:1> : <EOL> fields_to_trans_models = get_fields_to_translatable_models ( model ) <EOL> if pieces [ <NUM_LIT:0> ] in fields_to_trans_models : <EOL> transmodel = fields_to_trans_models [ pieces [ <NUM_LIT:0> ] ] <EOL> rest = append_lookup_key ( transmodel , pieces [ <NUM_LIT:1> ] ) <EOL> fields = set ( '<STR_LIT>' . join ( pr ) for pr in itertools . product ( fields , rest ) ) <EOL> else : <EOL> fields = set ( '<STR_LIT>' % ( f , pieces [ <NUM_LIT:1> ] ) for f in fields ) <EOL> return fields <EOL> def append_lookup_keys ( model , fields ) : <EOL> return moves . reduce ( set . union , ( append_lookup_key ( model , field ) for field in fields ) , set ( ) ) <EOL> def rewrite_order_lookup_key ( model , lookup_key ) : <EOL> if lookup_key . startswith ( '<STR_LIT:->' ) : <EOL> return '<STR_LIT:->' + rewrite_lookup_key ( model , lookup_key [ <NUM_LIT:1> : ] ) <EOL> else : <EOL> return rewrite_lookup_key ( model , lookup_key ) <EOL> _F2TM_CACHE = { } <EOL> def get_fields_to_translatable_models ( model ) : <EOL> if model in _F2TM_CACHE : <EOL> return _F2TM_CACHE [ model ] <EOL> results = [ ] <EOL> if NEW_META_API : <EOL> for f in model . _meta . get_fields ( ) : <EOL> if f . is_relation and f . related_model : <EOL> if get_translatable_fields_for_model ( f . related_model ) is not None : <EOL> results . append ( ( f . name , f . related_model ) ) <EOL> else : <EOL> for field_name in model . _meta . get_all_field_names ( ) : <EOL> field_object , modelclass , direct , m2m = model . _meta . get_field_by_name ( field_name ) <EOL> if direct and isinstance ( field_object , RelatedField ) : <EOL> if get_translatable_fields_for_model ( field_object . related . parent_model ) is not None : <EOL> results . append ( ( field_name , field_object . related . parent_model ) ) <EOL> if isinstance ( field_object , RelatedObject ) : <EOL> if get_translatable_fields_for_model ( field_object . model ) is not None : <EOL> results . append ( ( field_name , field_object . model ) ) <EOL> _F2TM_CACHE [ model ] = dict ( results ) <EOL> return _F2TM_CACHE [ model ] <EOL> _C2F_CACHE = { } <EOL> def get_field_by_colum_name ( model , col ) : <EOL> try : <EOL> field = model . _meta . get_field ( col ) <EOL> if field . column == col : <EOL> return field <EOL> except FieldDoesNotExist : <EOL> pass <EOL> field = _C2F_CACHE . get ( ( model , col ) , None ) <EOL> if field : <EOL> return field <EOL> for field in model . _meta . fields : <EOL> if field . column == col : <EOL> _C2F_CACHE [ ( model , col ) ] = field <EOL> return field <EOL> assert False , "<STR_LIT>" % col <EOL> class MultilingualQuerySet ( models . query . QuerySet ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( MultilingualQuerySet , self ) . __init__ ( * args , ** kwargs ) <EOL> self . _post_init ( ) <EOL> def _post_init ( self ) : <EOL> self . _rewrite = True <EOL> self . _populate = None <EOL> if self . model and ( not self . query . order_by ) : <EOL> if self . model . _meta . ordering : <EOL> ordering = [ ] <EOL> for key in self . model . _meta . ordering : <EOL> ordering . append ( rewrite_order_lookup_key ( self . model , key ) ) <EOL> self . query . add_ordering ( * ordering ) <EOL> def __reduce__ ( self ) : <EOL> return multilingual_queryset_factory , ( self . __class__ . __bases__ [ <NUM_LIT:0> ] , ) , self . __getstate__ ( ) <EOL> if NEW_RELATED_API : <EOL> def _clone ( self , klass = None , ** kwargs ) : <EOL> kwargs . setdefault ( '<STR_LIT>' , self . _rewrite ) <EOL> kwargs . setdefault ( '<STR_LIT>' , self . _populate ) <EOL> if hasattr ( self , '<STR_LIT>' ) : <EOL> kwargs . setdefault ( '<STR_LIT>' , self . translation_fields ) <EOL> if hasattr ( self , '<STR_LIT>' ) : <EOL> kwargs . setdefault ( '<STR_LIT>' , self . fields_to_del ) <EOL> if hasattr ( self , '<STR_LIT>' ) : <EOL> kwargs . setdefault ( '<STR_LIT>' , self . original_fields ) <EOL> return super ( MultilingualQuerySet , self ) . _clone ( ** kwargs ) <EOL> else : <EOL> def _clone ( self , klass = None , * args , ** kwargs ) : <EOL> if klass is not None and not issubclass ( klass , MultilingualQuerySet ) : <EOL> class NewClass ( klass , MultilingualQuerySet ) : <EOL> pass <EOL> NewClass . __name__ = '<STR_LIT>' % klass . __name__ <EOL> klass = NewClass <EOL> kwargs . setdefault ( '<STR_LIT>' , self . _rewrite ) <EOL> kwargs . setdefault ( '<STR_LIT>' , self . _populate ) <EOL> return super ( MultilingualQuerySet , self ) . _clone ( klass , * args , ** kwargs ) <EOL> def rewrite ( self , mode = True ) : <EOL> return self . _clone ( _rewrite = mode ) <EOL> def populate ( self , mode = '<STR_LIT:all>' ) : <EOL> """<STR_LIT>""" <EOL> return self . _clone ( _populate = mode ) <EOL> def _rewrite_applied_operations ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _rewrite_where ( self . query . where ) <EOL> if not NEW_RELATED_API : <EOL> self . _rewrite_where ( self . query . having ) <EOL> self . _rewrite_order ( ) <EOL> self . _rewrite_select_related ( ) <EOL> def select_related ( self , * fields , ** kwargs ) : <EOL> if not self . _rewrite : <EOL> return super ( MultilingualQuerySet , self ) . select_related ( * fields , ** kwargs ) <EOL> new_args = [ ] <EOL> for key in fields : <EOL> new_args . append ( rewrite_lookup_key ( self . model , key ) ) <EOL> return super ( MultilingualQuerySet , self ) . select_related ( * new_args , ** kwargs ) <EOL> def _rewrite_col ( self , col ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( col , Col ) : <EOL> new_name = rewrite_lookup_key ( self . model , col . target . name ) <EOL> if col . target . name != new_name : <EOL> new_field = self . model . _meta . get_field ( new_name ) <EOL> if col . target is col . source : <EOL> col . source = new_field <EOL> col . target = new_field <EOL> elif hasattr ( col , '<STR_LIT>' ) : <EOL> self . _rewrite_col ( col . col ) <EOL> elif hasattr ( col , '<STR_LIT>' ) : <EOL> self . _rewrite_col ( col . lhs ) <EOL> def _rewrite_where ( self , q ) : <EOL> """<STR_LIT>""" <EOL> if not NEW_LOOKUPS and isinstance ( q , tuple ) and isinstance ( q [ <NUM_LIT:0> ] , Constraint ) : <EOL> c = q [ <NUM_LIT:0> ] <EOL> if c . field is None : <EOL> c . field = get_field_by_colum_name ( self . model , c . col ) <EOL> new_name = rewrite_lookup_key ( self . model , c . field . name ) <EOL> if c . field . name != new_name : <EOL> c . field = self . model . _meta . get_field ( new_name ) <EOL> c . col = c . field . column <EOL> elif NEW_LOOKUPS and isinstance ( q , Lookup ) : <EOL> self . _rewrite_col ( q . lhs ) <EOL> if isinstance ( q , Node ) : <EOL> for child in q . children : <EOL> self . _rewrite_where ( child ) <EOL> def _rewrite_order ( self ) : <EOL> self . query . order_by = [ rewrite_order_lookup_key ( self . model , field_name ) <EOL> for field_name in self . query . order_by ] <EOL> def _rewrite_select_related ( self ) : <EOL> if isinstance ( self . query . select_related , dict ) : <EOL> new = { } <EOL> for field_name , value in self . query . select_related . items ( ) : <EOL> new [ rewrite_order_lookup_key ( self . model , field_name ) ] = value <EOL> self . query . select_related = new <EOL> def _rewrite_q ( self , q ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( q , tuple ) and len ( q ) == <NUM_LIT:2> : <EOL> return rewrite_lookup_key ( self . model , q [ <NUM_LIT:0> ] ) , q [ <NUM_LIT:1> ] <EOL> if isinstance ( q , Node ) : <EOL> q . children = list ( map ( self . _rewrite_q , q . children ) ) <EOL> return q <EOL> def _rewrite_f ( self , q ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( q , models . F ) : <EOL> q . name = rewrite_lookup_key ( self . model , q . name ) <EOL> return q <EOL> if isinstance ( q , Node ) : <EOL> q . children = list ( map ( self . _rewrite_f , q . children ) ) <EOL> if hasattr ( q , '<STR_LIT>' ) : <EOL> q . lhs = self . _rewrite_f ( q . lhs ) <EOL> if hasattr ( q , '<STR_LIT>' ) : <EOL> q . rhs = self . _rewrite_f ( q . rhs ) <EOL> return q <EOL> def _filter_or_exclude ( self , negate , * args , ** kwargs ) : <EOL> if not self . _rewrite : <EOL> return super ( MultilingualQuerySet , self ) . _filter_or_exclude ( negate , * args , ** kwargs ) <EOL> args = map ( self . _rewrite_q , args ) <EOL> for key , val in list ( kwargs . items ( ) ) : <EOL> new_key = rewrite_lookup_key ( self . model , key ) <EOL> del kwargs [ key ] <EOL> kwargs [ new_key ] = self . _rewrite_f ( val ) <EOL> return super ( MultilingualQuerySet , self ) . _filter_or_exclude ( negate , * args , ** kwargs ) <EOL> def _get_original_fields ( self ) : <EOL> source = ( self . model . _meta . concrete_fields if hasattr ( self . model . _meta , '<STR_LIT>' ) <EOL> else self . model . _meta . fields ) <EOL> return [ f . attname for f in source if not isinstance ( f , TranslationField ) ] <EOL> def order_by ( self , * field_names ) : <EOL> """<STR_LIT>""" <EOL> if not self . _rewrite : <EOL> return super ( MultilingualQuerySet , self ) . order_by ( * field_names ) <EOL> new_args = [ ] <EOL> for key in field_names : <EOL> new_args . append ( rewrite_order_lookup_key ( self . model , key ) ) <EOL> return super ( MultilingualQuerySet , self ) . order_by ( * new_args ) <EOL> def update ( self , ** kwargs ) : <EOL> if not self . _rewrite : <EOL> return super ( MultilingualQuerySet , self ) . update ( ** kwargs ) <EOL> for key , val in list ( kwargs . items ( ) ) : <EOL> new_key = rewrite_lookup_key ( self . model , key ) <EOL> del kwargs [ key ] <EOL> kwargs [ new_key ] = self . _rewrite_f ( val ) <EOL> return super ( MultilingualQuerySet , self ) . update ( ** kwargs ) <EOL> update . alters_data = True <EOL> @ property <EOL> def _populate_mode ( self ) : <EOL> if self . _populate is None : <EOL> return settings . AUTO_POPULATE <EOL> return self . _populate <EOL> def create ( self , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> with auto_populate ( self . _populate_mode ) : <EOL> return super ( MultilingualQuerySet , self ) . create ( ** kwargs ) <EOL> def get_or_create ( self , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> with auto_populate ( self . _populate_mode ) : <EOL> return super ( MultilingualQuerySet , self ) . get_or_create ( ** kwargs ) <EOL> def defer ( self , * fields ) : <EOL> fields = append_lookup_keys ( self . model , fields ) <EOL> return super ( MultilingualQuerySet , self ) . defer ( * fields ) <EOL> def only ( self , * fields ) : <EOL> fields = append_lookup_keys ( self . model , fields ) <EOL> return super ( MultilingualQuerySet , self ) . only ( * fields ) <EOL> def raw_values ( self , * fields ) : <EOL> return super ( MultilingualQuerySet , self ) . values ( * fields ) <EOL> def _values ( self , * original , ** kwargs ) : <EOL> if not kwargs . get ( '<STR_LIT>' , False ) : <EOL> return super ( MultilingualQuerySet , self ) . _values ( * original ) <EOL> new_fields , translation_fields = append_fallback ( self . model , original ) <EOL> clone = super ( MultilingualQuerySet , self ) . _values ( * list ( new_fields ) ) <EOL> clone . original_fields = tuple ( original ) <EOL> clone . translation_fields = translation_fields <EOL> clone . fields_to_del = new_fields - set ( original ) <EOL> return clone <EOL> def values ( self , * fields ) : <EOL> if not self . _rewrite : <EOL> return super ( MultilingualQuerySet , self ) . values ( * fields ) <EOL> if not fields : <EOL> fields = self . _get_original_fields ( ) <EOL> if NEW_RELATED_API : <EOL> clone = self . _values ( * fields , prepare = True ) <EOL> clone . _iterable_class = FallbackValuesIterable <EOL> return clone <EOL> else : <EOL> return self . _clone ( klass = FallbackValuesQuerySet , setup = True , _fields = fields ) <EOL> def values_list ( self , * fields , ** kwargs ) : <EOL> if not self . _rewrite : <EOL> return super ( MultilingualQuerySet , self ) . values_list ( * fields , ** kwargs ) <EOL> flat = kwargs . pop ( '<STR_LIT>' , False ) <EOL> if kwargs : <EOL> raise TypeError ( '<STR_LIT>' % ( list ( kwargs ) , ) ) <EOL> if flat and len ( fields ) > <NUM_LIT:1> : <EOL> raise TypeError ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> if not fields : <EOL> fields = self . _get_original_fields ( ) <EOL> if NEW_RELATED_API : <EOL> clone = self . _values ( * fields , prepare = True ) <EOL> clone . _iterable_class = ( FallbackFlatValuesListIterable if flat <EOL> else FallbackValuesListIterable ) <EOL> return clone <EOL> else : <EOL> return self . _clone ( klass = FallbackValuesListQuerySet , setup = True , flat = flat , <EOL> _fields = fields ) <EOL> def dates ( self , field_name , * args , ** kwargs ) : <EOL> if not self . _rewrite : <EOL> return super ( MultilingualQuerySet , self ) . dates ( field_name , * args , ** kwargs ) <EOL> new_key = rewrite_lookup_key ( self . model , field_name ) <EOL> return super ( MultilingualQuerySet , self ) . dates ( new_key , * args , ** kwargs ) <EOL> if NEW_RELATED_API : <EOL> class FallbackValuesIterable ( ValuesIterable ) : <EOL> class X ( object ) : <EOL> pass <EOL> def __iter__ ( self ) : <EOL> instance = self . X ( ) <EOL> for row in super ( FallbackValuesIterable , self ) . __iter__ ( ) : <EOL> instance . __dict__ . update ( row ) <EOL> for key in self . queryset . translation_fields : <EOL> row [ key ] = getattr ( self . queryset . model , key ) . __get__ ( instance , None ) <EOL> for key in self . queryset . fields_to_del : <EOL> del row [ key ] <EOL> yield row <EOL> class FallbackValuesListIterable ( FallbackValuesIterable ) : <EOL> def __iter__ ( self ) : <EOL> fields = self . queryset . original_fields <EOL> fields += tuple ( f for f in self . queryset . query . annotation_select if f not in fields ) <EOL> for row in super ( FallbackValuesListIterable , self ) . __iter__ ( ) : <EOL> yield tuple ( row [ f ] for f in fields ) <EOL> class FallbackFlatValuesListIterable ( FallbackValuesListIterable ) : <EOL> def __iter__ ( self ) : <EOL> for row in super ( FallbackFlatValuesListIterable , self ) . __iter__ ( ) : <EOL> yield row [ <NUM_LIT:0> ] <EOL> else : <EOL> class FallbackValuesQuerySet ( ValuesQuerySet , MultilingualQuerySet ) : <EOL> def _setup_query ( self ) : <EOL> original = self . _fields <EOL> new_fields , self . translation_fields = append_fallback ( self . model , original ) <EOL> self . _fields = list ( new_fields ) <EOL> self . fields_to_del = new_fields - set ( original ) <EOL> super ( FallbackValuesQuerySet , self ) . _setup_query ( ) <EOL> class X ( object ) : <EOL> pass <EOL> def iterator ( self ) : <EOL> instance = self . X ( ) <EOL> for row in super ( FallbackValuesQuerySet , self ) . iterator ( ) : <EOL> instance . __dict__ . update ( row ) <EOL> for key in self . translation_fields : <EOL> row [ key ] = getattr ( self . model , key ) . __get__ ( instance , None ) <EOL> for key in self . fields_to_del : <EOL> del row [ key ] <EOL> yield row <EOL> def _clone ( self , klass = None , setup = False , ** kwargs ) : <EOL> c = super ( FallbackValuesQuerySet , self ) . _clone ( klass , ** kwargs ) <EOL> c . fields_to_del = self . fields_to_del <EOL> c . translation_fields = self . translation_fields <EOL> if setup and hasattr ( c , '<STR_LIT>' ) : <EOL> c . _setup_query ( ) <EOL> return c <EOL> class FallbackValuesListQuerySet ( FallbackValuesQuerySet ) : <EOL> def iterator ( self ) : <EOL> fields = self . original_fields <EOL> if hasattr ( self , '<STR_LIT>' ) : <EOL> fields += tuple ( f for f in self . aggregate_names if f not in fields ) <EOL> if hasattr ( self , '<STR_LIT>' ) : <EOL> fields += tuple ( f for f in self . annotation_names if f not in fields ) <EOL> for row in super ( FallbackValuesListQuerySet , self ) . iterator ( ) : <EOL> if self . flat and len ( fields ) == <NUM_LIT:1> : <EOL> yield row [ fields [ <NUM_LIT:0> ] ] <EOL> else : <EOL> yield tuple ( row [ f ] for f in fields ) <EOL> def _setup_query ( self ) : <EOL> self . original_fields = tuple ( self . _fields ) <EOL> super ( FallbackValuesListQuerySet , self ) . _setup_query ( ) <EOL> def _clone ( self , * args , ** kwargs ) : <EOL> clone = super ( FallbackValuesListQuerySet , self ) . _clone ( * args , ** kwargs ) <EOL> clone . original_fields = self . original_fields <EOL> if not hasattr ( clone , "<STR_LIT>" ) : <EOL> clone . flat = self . flat <EOL> return clone <EOL> def get_queryset ( obj ) : <EOL> if hasattr ( obj , '<STR_LIT>' ) : <EOL> return obj . get_queryset ( ) <EOL> else : <EOL> return obj . get_query_set ( ) <EOL> def multilingual_queryset_factory ( old_cls , instantiate = True ) : <EOL> if old_cls == models . query . QuerySet : <EOL> NewClass = MultilingualQuerySet <EOL> else : <EOL> class NewClass ( old_cls , MultilingualQuerySet ) : <EOL> pass <EOL> NewClass . __name__ = '<STR_LIT>' % old_cls . __name__ <EOL> return NewClass ( ) if instantiate else NewClass <EOL> class MultilingualQuerysetManager ( models . Manager ) : <EOL> """<STR_LIT>""" <EOL> def get_queryset ( self ) : <EOL> qs = get_queryset ( super ( MultilingualQuerysetManager , self ) ) <EOL> return self . _patch_queryset ( qs ) <EOL> def _patch_queryset ( self , qs ) : <EOL> qs . __class__ = multilingual_queryset_factory ( qs . __class__ , instantiate = False ) <EOL> qs . _post_init ( ) <EOL> qs . _rewrite_applied_operations ( ) <EOL> return qs <EOL> get_query_set = get_queryset <EOL> class MultilingualManager ( MultilingualQuerysetManager ) : <EOL> use_for_related_fields = True <EOL> def rewrite ( self , * args , ** kwargs ) : <EOL> return self . get_queryset ( ) . rewrite ( * args , ** kwargs ) <EOL> def populate ( self , * args , ** kwargs ) : <EOL> return self . get_queryset ( ) . populate ( * args , ** kwargs ) <EOL> def raw_values ( self , * args , ** kwargs ) : <EOL> return self . get_queryset ( ) . raw_values ( * args , ** kwargs ) <EOL> def get_queryset ( self ) : <EOL> """<STR_LIT>""" <EOL> qs = get_queryset ( super ( MultilingualManager , self ) ) <EOL> if isinstance ( qs , MultilingualQuerySet ) : <EOL> return qs <EOL> return self . _patch_queryset ( qs ) <EOL> get_query_set = get_queryset </s>
