#NEWLINE# def test_polymorphic__aggregate( self ) : #NEWLINE# #INDENT# ' test ModelX___field syntax on aggregate (should work for annotate either) ' #NEWLINE# Model2A . objects . create ( field1 = 'A1' ) #NEWLINE# Model2B . objects . create ( field1 = 'A1' , field2 = 'B2' ) #NEWLINE# Model2B . objects . create ( field1 = 'A1' , field2 = 'B2' ) #NEWLINE# result = Model2A . objects . aggregate ( cnt = Count ( 'Model2B___field2' ) ) #NEWLINE# self . assertEqual ( self , { #NEWLINE# #INDENT# 'cnt' : 2 , #NEWLINE# #UNINDENT# } ) #NEWLINE# with self . assertRaisesMessage ( AssertionError , 'PolymorphicModel: annotate()/aggregate(): ___ model lookup supported for keyword arguments only' ) : #NEWLINE# #INDENT# Model2A . objects . aggregate ( Count ( 'Model2B___field2' ) )