[2.2.x] Fixed #30906 -- Fixed an example of using the template system to generate CSV.

Backport of 05c3ef26a2 from master
This commit is contained in:
Hasan Ramezani 2019-10-25 08:11:11 +02:00 committed by Mariusz Felisiak
parent 7fe09e6d41
commit 9d627bf9b2
1 changed files with 2 additions and 4 deletions

View File

@ -105,7 +105,7 @@ template output the commas in a :ttag:`for` loop.
Here's an example, which generates the same CSV file as above:: Here's an example, which generates the same CSV file as above::
from django.http import HttpResponse from django.http import HttpResponse
from django.template import Context, loader from django.template import loader
def some_view(request): def some_view(request):
# Create the HttpResponse object with the appropriate CSV header. # Create the HttpResponse object with the appropriate CSV header.
@ -120,9 +120,7 @@ Here's an example, which generates the same CSV file as above::
) )
t = loader.get_template('my_template_name.txt') t = loader.get_template('my_template_name.txt')
c = Context({ c = {'data': csv_data}
'data': csv_data,
})
response.write(t.render(c)) response.write(t.render(c))
return response return response