Nick,

I think you're looking for this:

http://docs.djangoproject.com/en/dev/howto/outputting-csv/

Franklin


On Wed, Jul 21, 2010 at 5:38 PM, Nick <[email protected]> wrote:
> I would like to format the output of a values_list into something a
> little more usable for a CSV.
>
> My view is really simple
>
> def values_view(request)
>    list = MyModel.objects.values_list('id', 'name', 'type')
>    template = loader.get_template('mytemp.html')
>    c = Context({'list': list})
>    html = t.render(c)
>    HttpResponse(html)
>
> my template looks like this
>
> {% for item in list %}
> {{item}}
> {% endfor %}
>
> it spits out a list of things like this:
>
> (u'id', u'name', u'type), (u'id2', u'name2', u'type2)
>
> etc. etc.
>
> How can I format a values_list so I could return something like a
> table or csv?
>
> so:
>
> id, name, type
> id2, name, type
>
> etc. etc.
>
> Thanks for the help
> Nick
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>



-- 
Art, writing, journal: http://einspruch.com
Comics: http://themoonfellonme.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to