#NEWLINE# def test_reverse_selects( self ) : #NEWLINE# #INDENT# a3 = Article . objects . create ( headline = 'Third article' , pub_date = datetime . date ( 2005 , 7 , 27 ) , reporter_id = self . r . id ) #NEWLINE# Article . objects . create ( headline = 'Fourth article' , pub_date = datetime . date ( 2005 , 7 , 27 ) , reporter_id = self . r . id ) #NEWLINE# john_smith = [ '<Reporter: John Smith>' ] #NEWLINE# self . assertQuerysetEqual ( Reporter . objects . filter ( id__exact = self . r . id ) , john_smith ) #NEWLINE# self . assertQuerysetEqual ( Reporter . objects . filter ( pk = self . r . id ) , john_smith ) #NEWLINE# self . assertQuerysetEqual ( Reporter . objects . filter ( first_name__startswith = 'John' ) , john_smith ) #NEWLINE# self . assertQuerysetEqual ( Reporter . objects . filter ( article__id__exact = self . a . id ) , john_smith ) #NEWLINE# self . assertQuerysetEqual ( Reporter . objects . filter ( article__pk = self . a . id ) , john_smith ) #NEWLINE# self . assertQuerysetEqual ( Reporter . objects . filter ( article = self . a . id ) , john_smith ) #NEWLINE# self . assertQuerysetEqual ( Reporter . objects . filter ( article = self . a ) , john_smith ) #NEWLINE# self . assertQuerysetEqual ( Reporter . objects . filter ( article__in = [ self . a . id , a3 . id ] ) . distinct ( ) , john_smith ) #NEWLINE# self . assertQuerysetEqual ( Reporter . objects . filter ( article__in = [ self . a . id , a3 ] ) . distinct ( ) , john_smith ) #NEWLINE# self . assertQuerysetEqual ( Reporter . objects . filter ( article__in = [ self . a , a3 ] ) . distinct ( ) , john_smith ) #NEWLINE# self . assertQuerysetEqual ( Reporter . objects . filter ( article__headline__startswith = 'T' ) , [ '<Reporter: John Smith>' , '<Reporter: John Smith>' ] , ordered = False ) #NEWLINE# self . assertQuerysetEqual ( Reporter . objects . filter ( article__headline__startswith = 'T' ) . distinct ( ) , john_smith ) #NEWLINE# self . assertEqual ( Reporter . objects . filter ( article__headline__startswith = 'T' ) . count ( ) , 2 ) #NEWLINE# self . assertEqual ( Reporter . objects . filter ( article__headline__startswith = 'T' ) . distinct ( ) . count ( ) , 1 ) #NEWLINE# self . assertQuerysetEqual ( Reporter . objects . filter ( article__reporter__first_name__startswith = 'John' ) , [ '<Reporter: John Smith>' , '<Reporter: John Smith>' , '<Reporter: John Smith>' ] , ordered = False ) #NEWLINE# self . assertQuerysetEqual ( Reporter . objects . filter ( article__reporter__first_name__startswith = 'John' ) . distinct ( ) , john_smith ) #NEWLINE# self . assertQuerysetEqual ( Reporter . objects . filter ( article__reporter__exact = self . r ) . distinct ( ) , john_smith ) #NEWLINE# self . assertQuerysetEqual ( Reporter . objects . filter ( article__reporter = self . r ) . distinct ( ) , john_smith ) #NEWLINE# d = { #NEWLINE# #INDENT# 'reporter__first_name' : 'John' , #NEWLINE# 'reporter__last_name' : 'Smith' , #NEWLINE# #UNINDENT# } #NEWLINE# qs = Article . objects . filter ( reporter = self . r ) . distinct ( ) . order_by ( ) . values ( 'reporter__first_name' , 'reporter__last_name' ) #NEWLINE# self . assertEqual ( [ d ] , list ( qs ) )