mirror of
https://github.com/django/django.git
synced 2025-03-31 19:46:42 +00:00
Fixed #30906 -- Fixed an example of using the template system to generate CSV.
This commit is contained in:
parent
cabf1fe37e
commit
05c3ef26a2
@ -104,7 +104,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.
|
||||||
@ -119,9 +119,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
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user