@allow_cross_site_request
@non_atomic_requests
def render_csv(request, addon, stats, fields, title=None, show_disclaimer=None):
 ts = time.strftime('%c %z')
 context = {'addon': addon, 'timestamp': ts, 'title': title, 'show_disclaimer': show_disclaimer}
 response = render(request, 'stats/csv_header.txt', context)
 writer = UnicodeCSVDictWriter(response, fields, restval=0, extrasaction='ignore')
 writer.writeheader()
 writer.writerows(stats)
 fudge_headers(response, stats)
 response['Content-Type'] = 'text/csv; charset=utf-8'
 return response

@ allow_cross_site_request @ non_atomic_requests def render_csv ( request , addon , stats , fields , title = None , show_disclaimer = None ) : ts = time . strftime ( '%c %z' ) context = { 'addon' : addon , 'timestamp' : ts , 'title' : title , 'show_disclaimer' : show_disclaimer } response = render ( request , 'stats/csv_header.txt' , context ) writer = UnicodeCSVDictWriter ( response , fields , restval = 0 , extrasaction = 'ignore' ) writer . writeheader ( ) writer . writerows ( stats ) fudge_headers ( response , stats ) response [ 'Content-Type' ] = 'text/csv; charset=utf-8' return response
render a stats series in csv .