summaryrefslogtreecommitdiff
path: root/docs/outputting_csv.txt
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2006-05-02 01:31:56 +0000
committerAdrian Holovaty <adrian@holovaty.com>2006-05-02 01:31:56 +0000
commitf69cf70ed813a8cd7e1f963a14ae39103e8d5265 (patch)
treed3b32e84cd66573b3833ddf662af020f8ef2f7a8 /docs/outputting_csv.txt
parentd5dbeaa9be359a4c794885c2e9f1b5a7e5e51fb8 (diff)
MERGED MAGIC-REMOVAL BRANCH TO TRUNK. This change is highly backwards-incompatible. Please read http://code.djangoproject.com/wiki/RemovingTheMagic for upgrade instructions.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@2809 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/outputting_csv.txt')
-rw-r--r--docs/outputting_csv.txt14
1 files changed, 7 insertions, 7 deletions
diff --git a/docs/outputting_csv.txt b/docs/outputting_csv.txt
index 3f95b3600d..1970261891 100644
--- a/docs/outputting_csv.txt
+++ b/docs/outputting_csv.txt
@@ -30,7 +30,7 @@ and Django's ``HttpResponse`` objects are file-like objects.
Here's an example::
import csv
- from django.utils.httpwrappers import HttpResponse
+ from django.http import HttpResponse
def some_view(request):
# Create the HttpResponse object with the appropriate CSV header.
@@ -49,10 +49,10 @@ mention:
* The response gets a special mimetype, ``text/csv``. This tells
browsers that the document is a CSV file, rather than an HTML file. If
you leave this off, browsers will probably interpret the output as HTML,
- which would result in ugly, scary gobbledygook in the browser window.
+ which will result in ugly, scary gobbledygook in the browser window.
* The response gets an additional ``Content-Disposition`` header, which
- contains the name of the CSV file. This filename is arbitrary: Call it
+ contains the name of the CSV file. This filename is arbitrary; call it
whatever you want. It'll be used by browsers in the "Save as..."
dialogue, etc.
@@ -79,8 +79,8 @@ template output the commas in a ``{% for %}`` loop.
Here's an example, which generates the same CSV file as above::
- from django.utils.httpwrappers import HttpResponse
- from django.core.template import loader, Context
+ from django.http import HttpResponse
+ from django.template import loader, Context
def some_view(request):
# Create the HttpResponse object with the appropriate CSV header.
@@ -94,7 +94,7 @@ Here's an example, which generates the same CSV file as above::
('Second row', 'A', 'B', 'C', '"Testing"', "Here's a quote"),
)
- t = loader.get_template('my_template_name')
+ t = loader.get_template('my_template_name.txt')
c = Context({
'data': csv_data,
})
@@ -105,7 +105,7 @@ The only difference between this example and the previous example is that this
one uses template loading instead of the CSV module. The rest of the code --
such as the ``mimetype='text/csv'`` -- is the same.
-Then, create the template ``my_template_name``, with this template code::
+Then, create the template ``my_template_name.txt``, with this template code::
{% for row in data %}"{{ row.0|addslashes }}", "{{ row.1|addslashes }}", "{{ row.2|addslashes }}", "{{ row.3|addslashes }}", "{{ row.4|addslashes }}"
{% endfor %}