def foo(request,...): model = get_object_or_404(Foo,...) data = model.get_data() # should return csv formatted string return HttpResponse(data,content_type='text/csv')