#NEWLINE# def test_generic_relation_ordering( self ) : #NEWLINE# #INDENT# '\n        Test that ordering over a generic relation does not include extraneous\n        duplicate results, nor excludes rows not participating in the relation.\n        ' #NEWLINE# p1 = Place . objects . create ( name = 'South Park' ) #NEWLINE# p2 = Place . objects . create ( name = 'The City' ) #NEWLINE# c = Company . objects . create ( name = "Chubby's Intl." ) #NEWLINE# Link . objects . create ( content_object = p1 ) #NEWLINE# Link . objects . create ( content_object = c ) #NEWLINE# places = list ( Place . objects . order_by ( 'links__id' ) ) #NEWLINE# def count_places( place ) : #NEWLINE# #INDENT# return len ( [ p for p in places if ( p . id == place . id ) ] ) #NEWLINE# #UNINDENT# self . assertEqual ( len ( c ) , 2 ) #NEWLINE# self . assertEqual ( count_places ( p1 ) , 1 ) #NEWLINE# self . assertEqual ( count_places ( p2 ) , 1 )