#NEWLINE# def get_total_count( self ) : #NEWLINE# #INDENT# '\n        Calling `len()` on a QuerySet would execute the whole SELECT.\n        See `/blog/2012/0124`\n        ' #NEWLINE# di = self . data_iterator #NEWLINE# if isinstance ( self , QuerySet ) : #NEWLINE# #INDENT# return di . count ( ) #NEWLINE# #UNINDENT# if False : #NEWLINE# #INDENT# return len ( di ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# return len ( di ) #NEWLINE# #UNINDENT# except TypeError : #NEWLINE# #INDENT# raise TypeError ( '{0} has no length' . format ( di ) )