#NEWLINE# def add_date_select( self , field_name , lookup_type , order = 'ASC' ) : #NEWLINE# #INDENT# '\n        Converts the query into a date extraction query.\n        ' #NEWLINE# try : #NEWLINE# #INDENT# result = self . setup_joins ( field_name . split ( LOOKUP_SEP ) , self . get_meta ( ) , self . get_initial_alias ( ) , False ) #NEWLINE# #UNINDENT# except FieldError : #NEWLINE# #INDENT# raise FieldDoesNotExist ( ( "%s has no field named '%s'" % ( self . model . _meta . object_name , field_name ) ) ) #NEWLINE# #UNINDENT# field = result [ 0 ] #NEWLINE# assert isinstance ( field , DateField ) , ( "%r isn't a DateField." % field . name ) #NEWLINE# alias = result [ 3 ] [ ( - 1 ) ] #NEWLINE# select = Date ( ( alias , field . column ) , lookup_type ) #NEWLINE# self . select = [ select ] #NEWLINE# self . select_fields = [ None ] #NEWLINE# self . select_related = False #NEWLINE# self . set_extra_mask ( [ ] ) #NEWLINE# self . distinct = True #NEWLINE# self . order_by = ( ( ( order == 'ASC' ) and [ 1 ] ) or [ ( - 1 ) ] ) #NEWLINE# if field . null : #NEWLINE# #INDENT# self . add_filter ( ( ( '%s__isnull' % field_name ) , False ) )