@@ -177,12 +177,20 @@ class TranslationQueryset(QuerySet):
177177 override_classes [DateTimeQuerySet ] = SkipMasterSelectMixin
178178 _skip_master_select = False
179179
180- def __init__ (self , model , * args , ** kwargs ):
181- if hasattr (model ._meta , 'translations_model' ):
182- # normal creation gets a shared model that we must flip around
183- model , self .shared_model = model ._meta .translations_model , model
184- elif not hasattr (model ._meta , 'shared_model' ):
185- raise TypeError ('TranslationQueryset only works on translatable models' )
180+ def __init__ (self , * args , ** kwargs ):
181+ # model can be either first positional, or a named arg
182+ if len (args ) >= 1 :
183+ model , args = args [0 ], args [1 :]
184+ else :
185+ model = kwargs .pop ('model' , None )
186+
187+ if model is not None : # check the given model is correct
188+ if hasattr (model ._meta , 'translations_model' ):
189+ # normal creation gets a shared model that we must flip around
190+ model , self .shared_model = model ._meta .translations_model , model
191+ elif not hasattr (model ._meta , 'shared_model' ):
192+ raise TypeError ('TranslationQueryset only works on translatable models' )
193+
186194 self ._local_field_names = None
187195 self ._field_translator = None
188196 self ._language_code = None
0 commit comments