diff options
| author | Tom Carrick <tom@carrick.eu> | 2020-07-14 13:32:24 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-09-14 08:41:59 +0200 |
| commit | bcc2befd0e9c1885e45b46d0b0bcdc11def8b249 (patch) | |
| tree | 59fab69a3182286da87fcd6fe05a8ce0f4277a5a /docs/howto/outputting-csv.txt | |
| parent | 71ae1ab0123582cc5bfe0f7d5f4cc19a9412f396 (diff) | |
Fixed #31789 -- Added a new headers interface to HttpResponse.
Diffstat (limited to 'docs/howto/outputting-csv.txt')
| -rw-r--r-- | docs/howto/outputting-csv.txt | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/docs/howto/outputting-csv.txt b/docs/howto/outputting-csv.txt index 2886a1b294..dc3cf57cfd 100644 --- a/docs/howto/outputting-csv.txt +++ b/docs/howto/outputting-csv.txt @@ -21,7 +21,7 @@ Here's an example:: def some_view(request): # Create the HttpResponse object with the appropriate CSV header. response = HttpResponse(content_type='text/csv') - response['Content-Disposition'] = 'attachment; filename="somefilename.csv"' + response.headers['Content-Disposition'] = 'attachment; filename="somefilename.csv"' writer = csv.writer(response) writer.writerow(['First row', 'Foo', 'Bar', 'Baz']) @@ -88,7 +88,7 @@ the assembly and transmission of a large CSV file:: writer = csv.writer(pseudo_buffer) response = StreamingHttpResponse((writer.writerow(row) for row in rows), content_type="text/csv") - response['Content-Disposition'] = 'attachment; filename="somefilename.csv"' + response.headers['Content-Disposition'] = 'attachment; filename="somefilename.csv"' return response Using the template system @@ -109,7 +109,7 @@ Here's an example, which generates the same CSV file as above:: def some_view(request): # Create the HttpResponse object with the appropriate CSV header. response = HttpResponse(content_type='text/csv') - response['Content-Disposition'] = 'attachment; filename="somefilename.csv"' + response.headers['Content-Disposition'] = 'attachment; filename="somefilename.csv"' # The data is hard-coded here, but you could load it from a database or # some other source. |
