#NEWLINE# def test_prefetch_related_from_uuid_model_to_uuid_model( self ) : #NEWLINE# #INDENT# fleas = [ Flea . objects . create ( ) for i in range ( 3 ) ] #NEWLINE# Pet . objects . create ( name = 'Fifi' ) . fleas_hosted . add ( * fleas ) #NEWLINE# Pet . objects . create ( name = 'Bobo' ) . fleas_hosted . add ( * fleas ) #NEWLINE# with self . assertNumQueries ( 2 ) : #NEWLINE# #INDENT# pet = Pet . objects . prefetch_related ( 'fleas_hosted' ) . get ( name = 'Fifi' ) #NEWLINE# #UNINDENT# with self . assertNumQueries ( 0 ) : #NEWLINE# #INDENT# self . assertEqual ( 3 , len ( pet . fleas_hosted . all ( ) ) ) #NEWLINE# #UNINDENT# with self . assertNumQueries ( 2 ) : #NEWLINE# #INDENT# flea = Flea . objects . prefetch_related ( 'pets_visited' ) . get ( pk = fleas [ 0 ] . pk ) #NEWLINE# #UNINDENT# with self . assertNumQueries ( 0 ) : #NEWLINE# #INDENT# self . assertEqual ( 2 , len ( flea . pets_visited . all ( ) ) )