maybe this way: from django.shortcuts import get_list_or_404 from MY_APP.models *
def values_view(request) list = get_list_or_404(MyModel) template = loader.get_template('mytemp.html') c = Context({'list': list}) html = t.render(c) HttpResponse(html) Template: {% for item in list %} {{item.id}}, {{item.name}}, {{item.type}} {% endfor %} On 07/21/10 23:38, Nick 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 >
signature.asc
Description: OpenPGP digital signature