#NEWLINE# def test_subquery( self ) : #NEWLINE# #INDENT# 'Make sure as_sql works with subqueries and primary/replica.' #NEWLINE# mark = Person . objects . using ( 'other' ) . create ( name = 'Mark Pilgrim' ) #NEWLINE# Book . objects . using ( 'other' ) . create ( title = 'Dive into Python' , published = datetime . date ( 2009 , 5 , 4 ) , editor = mark ) #NEWLINE# sub = Person . objects . filter ( name = 'Mark Pilgrim' ) #NEWLINE# qs = Book . objects . filter ( editor__in = sub ) #NEWLINE# str ( self . query ) #NEWLINE# self . assertEqual ( list ( qs . values_list ( 'title' , flat = True ) ) , [ 'Dive into Python' ] )