#NEWLINE# def get_by_model( self , queryset_or_model , tags ) : #NEWLINE# #INDENT# '\n        Create a ``QuerySet`` containing instances of the specified\n        model associated with a given tag or list of tags.\n        ' #NEWLINE# tags = get_tag_list ( tags ) #NEWLINE# tag_count = len ( tags ) #NEWLINE# ( queryset , model ) = get_queryset_and_model ( queryset_or_model ) #NEWLINE# if ( tag_count == 0 ) : #NEWLINE# #INDENT# return model . _default_manager . none ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( tag_count == 1 ) : #NEWLINE# #INDENT# tag = tags [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return self . get_intersection_by_model ( queryset_or_model , tags ) #NEWLINE# #UNINDENT# #UNINDENT# content_type = ContentType . objects . get_for_model ( model ) #NEWLINE# opts = self . model . _meta #NEWLINE# tagged_item_table = qn ( opts . db_table ) #NEWLINE# return queryset . active ( ) . extra ( tables = [ opts . db_table ] , where = [ ( '%s.content_type_id = %%s' % tagged_item_table ) , ( '%s.tag_id = %%s' % tagged_item_table ) , ( '%s.%s = %s.object_id' % ( qn ( model . _meta . db_table ) , qn ( model . _meta . pk . column ) , tagged_item_table ) ) ] , params = [ content_type . pk , tag . pk ] )