Changeset 2784
- Timestamp:
- 04/28/06 20:57:51 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/magic-removal/docs/outputting_csv.txt
r1948 r2784 50 50 browsers that the document is a CSV file, rather than an HTML file. If 51 51 you leave this off, browsers will probably interpret the output as HTML, 52 which w ouldresult in ugly, scary gobbledygook in the browser window.52 which will result in ugly, scary gobbledygook in the browser window. 53 53 54 54 * The response gets an additional ``Content-Disposition`` header, which 55 contains the name of the CSV file. This filename is arbitrary : Call it55 contains the name of the CSV file. This filename is arbitrary; call it 56 56 whatever you want. It'll be used by browsers in the "Save as..." 57 57 dialogue, etc. … … 95 95 ) 96 96 97 t = loader.get_template('my_template_name ')97 t = loader.get_template('my_template_name.txt') 98 98 c = Context({ 99 99 'data': csv_data, … … 106 106 such as the ``mimetype='text/csv'`` -- is the same. 107 107 108 Then, create the template ``my_template_name ``, with this template code::108 Then, create the template ``my_template_name.txt``, with this template code:: 109 109 110 110 {% for row in data %}"{{ row.0|addslashes }}", "{{ row.1|addslashes }}", "{{ row.2|addslashes }}", "{{ row.3|addslashes }}", "{{ row.4|addslashes }}"
