#NEWLINE# def archive_year( request , year , queryset , date_field , template_name = None , template_loader = loader , extra_context = None , allow_empty = False , context_processors = None , template_object_name = 'object' , mimetype = None , make_object_list = False , allow_future = False ) : #NEWLINE# #INDENT# '\n    Generic yearly archive view.\n\n    Templates: ``<app_label>/<model_name>_archive_year.html``\n    Context:\n        date_list\n            List of months in this year with objects\n        year\n            This year\n        object_list\n            List of objects published in the given month\n            (Only available if make_object_list argument is True)\n    ' #NEWLINE# if ( extra_context is None ) : #NEWLINE# #INDENT# extra_context = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# model = queryset . model #NEWLINE# now = timezone . now ( ) #NEWLINE# lookup_kwargs = { #NEWLINE# #INDENT# ( '%s__year' % date_field ) : year , #NEWLINE# #UNINDENT# } #NEWLINE# if ( ( int ( year ) >= now . year ) and ( not allow_future ) ) : #NEWLINE# #INDENT# lookup_kwargs [ ( '%s__lte' % date_field ) ] = now #NEWLINE# #UNINDENT# date_list = queryset . filter ( ** lookup_kwargs ) . dates ( date_field , 'month' ) #NEWLINE# if ( ( not date_list ) and ( not allow_empty ) ) : #NEWLINE# #INDENT# raise Http404 #NEWLINE# #UNINDENT# if make_object_list : #NEWLINE# #INDENT# object_list = queryset . filter ( ** lookup_kwargs ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# object_list = [ ] #NEWLINE# #UNINDENT# if ( not template_name ) : #NEWLINE# #INDENT# template_name = ( '%s/%s_archive_year.html' % ( model . _meta . app_label , model . _meta . object_name . lower ( ) ) ) #NEWLINE# #UNINDENT# t = template_loader . get_template ( template_name ) #NEWLINE# c = RequestContext ( request , { #NEWLINE# #INDENT# 'date_list' : date_list , #NEWLINE# 'year' : year , #NEWLINE# ( '%s_list' % template_object_name ) : object_list , #NEWLINE# #UNINDENT# } , context_processors ) #NEWLINE# for ( key , value ) in extra_context . items ( ) : #NEWLINE# #INDENT# if callable ( value ) : #NEWLINE# #INDENT# c [ key ] = value ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# c [ key ] = value #NEWLINE# #UNINDENT# #UNINDENT# return HttpResponse ( t . render ( c ) , mimetype = mimetype )