Django

Code

Show
Ignore:
Timestamp:
05/01/06 20:31:56 (3 years ago)
Author:
adrian
Message:

MERGED MAGIC-REMOVAL BRANCH TO TRUNK. This change is highly backwards-incompatible. Please read http://code.djangoproject.com/wiki/RemovingTheMagic for upgrade instructions.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/outputting_csv.txt

    r1172 r2809  
    3131 
    3232    import csv 
    33     from django.utils.httpwrappers import HttpResponse 
     33    from django.http import HttpResponse 
    3434 
    3535    def some_view(request): 
     
    5050      browsers that the document is a CSV file, rather than an HTML file. If 
    5151      you leave this off, browsers will probably interpret the output as HTML, 
    52       which would result in ugly, scary gobbledygook in the browser window. 
     52      which will result in ugly, scary gobbledygook in the browser window. 
    5353 
    5454    * The response gets an additional ``Content-Disposition`` header, which 
    55       contains the name of the CSV file. This filename is arbitrary: Call it 
     55      contains the name of the CSV file. This filename is arbitrary; call it 
    5656      whatever you want. It'll be used by browsers in the "Save as..." 
    5757      dialogue, etc. 
     
    8080Here's an example, which generates the same CSV file as above:: 
    8181 
    82     from django.utils.httpwrappers import HttpResponse 
    83     from django.core.template import loader, Context 
     82    from django.http import HttpResponse 
     83    from django.template import loader, Context 
    8484 
    8585    def some_view(request): 
     
    9595        ) 
    9696 
    97         t = loader.get_template('my_template_name') 
     97        t = loader.get_template('my_template_name.txt') 
    9898        c = Context({ 
    9999            'data': csv_data, 
     
    106106such as the ``mimetype='text/csv'`` -- is the same. 
    107107 
    108 Then, create the template ``my_template_name``, with this template code:: 
     108Then, create the template ``my_template_name.txt``, with this template code:: 
    109109 
    110110    {% for row in data %}"{{ row.0|addslashes }}", "{{ row.1|addslashes }}", "{{ row.2|addslashes }}", "{{ row.3|addslashes }}", "{{ row.4|addslashes }}"