#NEWLINE# def __init__( self , * args , **kwargs ) : #NEWLINE# #INDENT# super ( YearMonthForm , self ) . __init__ ( * args , ** kwargs ) #NEWLINE# now = datetime . datetime . now ( ) #NEWLINE# this_year = now . year #NEWLINE# this_month = now . month #NEWLINE# try : #NEWLINE# #INDENT# first_entry = Entry . no_join . values ( 'end_time' ) . order_by ( 'end_time' ) [ 0 ] #NEWLINE# #UNINDENT# except IndexError : #NEWLINE# #INDENT# first_year = this_year #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# first_year = first_entry [ 'end_time' ] . year #NEWLINE# #UNINDENT# years = [ ( year , year ) for year in range ( first_year , ( this_year + 1 ) ) ] #NEWLINE# self . fields [ 'year' ] . choices = years #NEWLINE# initial = kwargs . get ( 'initial' ) #NEWLINE# if initial : #NEWLINE# #INDENT# this_year = initial . get ( 'year' , this_year ) #NEWLINE# this_month = initial . get ( 'month' , this_month ) #NEWLINE# #UNINDENT# self . fields [ 'year' ] . initial = this_year #NEWLINE# self . fields [ 'month' ] . initial = this_month