#NEWLINE# def total_document_version_per_month( ) : #NEWLINE# #INDENT# qss = qsstats . QuerySetStats ( DocumentVersion . objects . all ( ) , 'document__date_added' ) #NEWLINE# this_year = datetime . date . today ( ) . year #NEWLINE# result = [ ] #NEWLINE# for month in range ( 1 , ( datetime . date . today ( ) . month + 1 ) ) : #NEWLINE# #INDENT# next_month = ( month + 1 ) #NEWLINE# if ( next_month == 12 ) : #NEWLINE# #INDENT# next_month = 1 #NEWLINE# year = ( this_year + 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# next_month = ( month + 1 ) #NEWLINE# year = this_year #NEWLINE# #UNINDENT# result . append ( { #NEWLINE# #INDENT# month : qss . until ( datetime . date ( year , next_month , 1 ) ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# return { #NEWLINE# #INDENT# 'series' : { #NEWLINE# #INDENT# 'Versions' : result , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# }