On Monday, November 12, 2012, Daniel Roseman wrote:

> On Sunday, 11 November 2012 23:51:44 UTC, HA wrote:
>
>> Hi Folks,
>>
>> I want to export data from my named tuple within my django html template.
>> Can someone please point me to an example or let me know how to
>> accomplish this?
>> I know how to get this done within my python script but this time I want
>> to get this done inside of my html template page. Basically I want to have
>> a button which says "Export to CSV" on html page and clicking on it exports
>> data (from a named tuple) to a csv
>>
>
While I might agree with DR below, it should be pointed out, and is more
friendly to note, that the front page of the documentation has a link that
is called "Generating CSV", points to
/path/django-docs/howto/outputting-csv.html<file:///home/datakid/src/django-docs/howto/outputting-csv.html>
and
shows two techniques for outputting html, one using a view function (as per
below) and one using the template, as requested. Note that the template
solution is provided "for completeness" which I take to mean "the
developers cannot think of any use case, but admit that it is possible and
therefore give an example".

Also, a quick search will turn up a number of Django snippets that show how
to output a queryset; and I believe there's an "export anything to
anything" app as well.

cheers
L.


> This question makes no sense. Exporting data isn't something you do in a
> template, you do it in a view. Your template should just have a link to the
> view that does this.
> And what could it mean to have data in a "named tuple"? Assuming you mean
> collections.namedtuple, that's just a tuple with named fields, and is
> really only suitable for a small amount of data. How can you have enough
> data in a namedtuple to make it worth exporting to a CSV?
>


-- 
...we look at the present day through a rear-view mirror. This is something
Marshall McLuhan said back in the Sixties, when the world was in the grip
of authentic-seeming future narratives. He said, “We look at the present
through a rear-view mirror. We march backwards into the future.”

http://www.warrenellis.com/?p=14314

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

Reply via email to