#NEWLINE# def test_defer_fields( self ) : #NEWLINE# #INDENT# self . create_model2abcd ( ) #NEWLINE# objects_deferred = Model2A . objects . defer ( 'field1' ) #NEWLINE# self . assertNotIn ( 'field1' , objects_deferred [ 0 ] . __dict__ , 'field1 was not deferred (using defer())' ) #NEWLINE# self . assertEqual ( repr ( objects_deferred [ 0 ] ) , '<Model2A_Deferred_field1: id 1, field1 (CharField)>' ) #NEWLINE# self . assertEqual ( repr ( objects_deferred [ 1 ] ) , '<Model2B_Deferred_field1: id 2, field1 (CharField), field2 (CharField)>' ) #NEWLINE# self . assertEqual ( repr ( objects_deferred [ 2 ] ) , '<Model2C_Deferred_field1: id 3, field1 (CharField), field2 (CharField), field3 (CharField)>' ) #NEWLINE# self . assertEqual ( repr ( objects_deferred [ 3 ] ) , '<Model2D_Deferred_field1: id 4, field1 (CharField), field2 (CharField), field3 (CharField), field4 (CharField)>' ) #NEWLINE# objects_only = Model2A . objects . only ( 'pk' , 'polymorphic_ctype' , 'field1' ) #NEWLINE# self . assertIn ( 'field1' , objects_only [ 0 ] . __dict__ , 'qs.only("field1") was used, but field1 was incorrectly deferred' ) #NEWLINE# self . assertIn ( 'field1' , objects_only [ 3 ] . __dict__ , 'qs.only("field1") was used, but field1 was incorrectly deferred on a child model' ) #NEWLINE# self . assertNotIn ( 'field4' , objects_only [ 3 ] . __dict__ , 'field4 was not deferred (using only())' ) #NEWLINE# self . assertEqual ( repr ( objects_only [ 0 ] ) , '<Model2A: id 1, field1 (CharField)>' ) #NEWLINE# self . assertEqual ( repr ( objects_only [ 1 ] ) , '<Model2B_Deferred_field2: id 2, field1 (CharField), field2 (CharField)>' ) #NEWLINE# self . assertEqual ( repr ( objects_only [ 2 ] ) , '<Model2C_Deferred_field2_field3_model2a_ptr_id: id 3, field1 (CharField), field2 (CharField), field3 (CharField)>' ) #NEWLINE# self . assertEqual ( repr ( objects_only [ 3 ] ) , '<Model2D_Deferred_field2_field3_field4_model2a_ptr_id_model2b_ptr_id: id 4, field1 (CharField), field2 (CharField), field3 (CharField), field4 (CharField)>' )