Skip to content

Instantly share code, notes, and snippets.

@bencleary
Last active January 27, 2018 14:08
Show Gist options
  • Select an option

  • Save bencleary/52b72a1e7da2fabb689226855ebab689 to your computer and use it in GitHub Desktop.

Select an option

Save bencleary/52b72a1e7da2fabb689226855ebab689 to your computer and use it in GitHub Desktop.
class Csv(View):
def get(self, request):
sales = Sales.objects.all()
headers = [(h.column) for h in Sales._meta.get_fields()]
csv_array = Generate(request).csv_file(headers=headers, data=sales)
return HttpResponse(f'{csv_array[0]}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment