#NEWLINE# def pivot( self , dt , operator = None , date_field = None , aggregate_field = None , aggregate_class = None ) : #NEWLINE# #INDENT# date_field = ( self or self . date_field ) #NEWLINE# aggregate_class = ( aggregate_class or self . aggregate_class ) #NEWLINE# aggregate_field = ( aggregate_field or self . aggregate_field ) #NEWLINE# operator = ( operator or self . operator ) #NEWLINE# self . check_date_field ( date_field ) #NEWLINE# self . check_qs ( ) #NEWLINE# if ( operator not in [ 'lt' , 'lte' , 'gt' , 'gte' ] ) : #NEWLINE# #INDENT# raise InvalidOperator ( 'Please provide a valid operator.' ) #NEWLINE# #UNINDENT# kwargs = { #NEWLINE# #INDENT# ( '%s__%s' % ( date_field , operator ) ) : dt , #NEWLINE# #UNINDENT# } #NEWLINE# total = self . qs . filter ( ** kwargs ) . aggregate ( total = aggregate_class ( aggregate_field ) ) #NEWLINE# return total [ 'total' ]