#NEWLINE# def test_regression_22508( self ) : #NEWLINE# #INDENT# building = Building . objects . create ( name = '101' ) #NEWLINE# device = Device . objects . create ( name = 'router' , building = building ) #NEWLINE# Port . objects . create ( port_number = '1' , device = device ) #NEWLINE# device = Device . objects . get ( ) #NEWLINE# port = device . port_set . select_related ( 'device__building' ) . get ( ) #NEWLINE# with self . assertNumQueries ( 0 ) : #NEWLINE# #INDENT# port . device . building