Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ....
- <a href="/directory/download" class="btn btn-primary btn-xs" style="float: right;">Download</a>
- <table class="table table-striped">
- <thead>
- <tr>
- <th>Device</th>
- <th>Description</th>
- <th>Location</th>
- <th>Model</th>
- </tr>
- </thead>
- <tbody>
- {% for r in result %}
- <tr>
- <td>{{r.name}}</td>
- <td>{{r.description}}</td>
- <td>{{r.locationName.value}}</td>
- <td>{{r.model}}</td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- ...
- def download(request):
- import csv
- # print("downloading...")
- response = HttpResponse(content_type='text/csv')
- response['Content-Disposition'] = 'attachment; filename="report.csv"'
- writer = csv.writer(response)
- # write table to csv file
- return response
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement