0

I have a django template viewreports.html which prints some results based on calculation done in a view function view_reports. But I have added a button to download csv to the template. Upon clicking the button I want to pass the result values from viewreports.html to another view function getcsvreport where the csv is generated. I'm unable to pass lists through the url. Can someone explain how I can pass multiple variables(some of them lists) from a template to a view function(through the url or any other method)??

user6714507
  • 63
  • 1
  • 9
  • I would use ajax for this. See this question: [Passing list of values to django view via jquery ajax call](https://stackoverflow.com/questions/11176594/passing-list-of-values-to-django-view-via-jquery-ajax-call/11176647) – Martinez Jul 16 '18 at 13:04
  • I would have used the same view with an optional `format` kwarg/request param... If it is csv return a CSV file, else return the html response – Resley Rodrigues Jul 16 '18 at 13:05
  • Also depending on your frontend, there are lot of javascript libraries that allow you to export data to csv – Resley Rodrigues Jul 16 '18 at 13:06

0 Answers0