#NEWLINE# def test_m2m_to_inheriting_model( self ) : #NEWLINE# #INDENT# qs = AuthorWithAge . objects . prefetch_related ( 'books_with_year' ) #NEWLINE# with self . assertNumQueries ( 2 ) : #NEWLINE# #INDENT# lst = [ [ six . text_type ( book ) for book in author . books_with_year . all ( ) ] for author in qs ] #NEWLINE# #UNINDENT# qs = AuthorWithAge . objects . all ( ) #NEWLINE# lst2 = [ [ six . text_type ( book ) for book in author . books_with_year . all ( ) ] for author in qs ] #NEWLINE# self . assertEqual ( lst , lst2 ) #NEWLINE# qs = BookWithYear . objects . prefetch_related ( 'aged_authors' ) #NEWLINE# with self . assertNumQueries ( 2 ) : #NEWLINE# #INDENT# lst = [ [ six . text_type ( author ) for author in book . aged_authors . all ( ) ] for book in qs ] #NEWLINE# #UNINDENT# qs = BookWithYear . objects . all ( ) #NEWLINE# lst2 = [ [ six . text_type ( author ) for author in book . aged_authors . all ( ) ] for book in qs ] #NEWLINE# self . assertEqual ( lst , lst2 )