#NEWLINE# def template_view( modeladmin , request , form_url = '' , extra_context = None ) : #NEWLINE# #INDENT# '\n        A view function that returns a dynamically generated CSV file, based\n        on the geounits available in the application.\n        ' #NEWLINE# opts = modeladmin . model . _meta #NEWLINE# app_label = opts . app_label #NEWLINE# ( geolevel , nunits ) = LegislativeLevel . get_basest_geolevel_and_count ( ) #NEWLINE# context = { #NEWLINE# #INDENT# 'geounits' : geolevel . geounit_set . all ( ) . order_by ( 'portable_id' ) . values_list ( 'portable_id' , flat = True ) , #NEWLINE# #UNINDENT# } #NEWLINE# resp = render_to_response ( ( 'admin/%s/%s/add_template.csv' % ( app_label , opts . object_name . lower ( ) ) ) , dictionary = context , mimetype = 'text/plain' ) #NEWLINE# resp [ 'Content-Disposition' ] = 'attachement; filename=new_subject.csv' #NEWLINE# return resp