Advertisement
Guest User

Untitled

a guest
Aug 30th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. ....
  2. <a href="/directory/download" class="btn btn-primary btn-xs" style="float: right;">Download</a>
  3. <table class="table table-striped">
  4. <thead>
  5. <tr>
  6. <th>Device</th>
  7. <th>Description</th>
  8. <th>Location</th>
  9. <th>Model</th>
  10. </tr>
  11. </thead>
  12. <tbody>
  13. {% for r in result %}
  14. <tr>
  15. <td>{{r.name}}</td>
  16. <td>{{r.description}}</td>
  17. <td>{{r.locationName.value}}</td>
  18. <td>{{r.model}}</td>
  19. </tr>
  20. {% endfor %}
  21. </tbody>
  22. </table>
  23.  
  24. ...
  25.  
  26. def download(request):
  27. import csv
  28.  
  29. # print("downloading...")
  30. response = HttpResponse(content_type='text/csv')
  31. response['Content-Disposition'] = 'attachment; filename="report.csv"'
  32. writer = csv.writer(response)
  33.  
  34. # write table to csv file
  35.  
  36. return response
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement