> > Can you show me how I could modify form_query() to embed JS (if I've > understood your second option correctly) in order to trigger the download? >
You're not going to be able to have a single call to form_query both return HTML content and stream a file at the same time -- those are two separate HTTP responses, so you need two separate requests. Return the HTML first, and then request the file separately. If you don't want to repeat the query to re-generate the rows object again, in your select(), add cacheable=True. That will allow you to store rows in the session when form_query is called. Your subsequent call to fetch the file can then retrieve rows from the session, convert to csv, and then stream. Anthony --