[Fixed]-Passing list or array (as parameter) in Django View

1πŸ‘

It seems a waste of a round trip to send your data to the server and ask it to create a CSV when you can quite easily do that in the javascript itself. Less load on the server, faster response.

Assuming your link is like

<a href="" id="download_link">Download CSV</a>

Then

function to_csv(json_data, header, info){
    var s = "data:text/csv,"
    for (var key in json_data) {
        if (json_data.hasOwnProperty(key)) {
            s += json_data[key];
        }
    }
}
πŸ‘€e4c5

0πŸ‘

Solved this by using json.loads:

g_data = json.loads(request.GET.get('json_data'))
πŸ‘€Matt Mateo

Leave a comment