From bcc2befd0e9c1885e45b46d0b0bcdc11def8b249 Mon Sep 17 00:00:00 2001 From: Tom Carrick Date: Tue, 14 Jul 2020 13:32:24 +0200 Subject: Fixed #31789 -- Added a new headers interface to HttpResponse. --- docs/howto/outputting-csv.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'docs/howto') 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. -- cgit v1.3