Re: CSV output

2013-09-23 Thread C. Kirby
Whoops, missed the map step. I think you will need to create a new dict using the try/except above, and then map the new dict to str On Monday, September 23, 2013 5:29:40 PM UTC-5, C. Kirby wrote: > > try: > value = getattr(object, 'get_%s_display' % field)() > except: > v

Re: CSV output

2013-09-23 Thread C. Kirby
try: value = getattr(object, 'get_%s_display' % field)() except: value getattr(object, field) On Monday, September 23, 2013 4:47:33 PM UTC-5, Lachlan Musicman wrote: > > Ok, so here's the challenging part - how would you get the > get_FOO_display value for some but not all

Re: CSV output

2013-09-23 Thread Lachlan Musicman
Ok, so here's the challenging part - how would you get the get_FOO_display value for some but not all of those values? cheers L. On 23 September 2013 23:29, Valder Gallo wrote: > :D > > > > On Mon, Sep 23, 2013 at 10:12 AM, Lachlan Musicman > wrote: >> >> On 23 September 2013 22:47, Valder Gall

Re: CSV output

2013-09-23 Thread Valder Gallo
:D On Mon, Sep 23, 2013 at 10:12 AM, Lachlan Musicman wrote: > On 23 September 2013 22:47, Valder Gallo wrote: > > Sorry, i really don´t understand why you need this. > > To mail merge details taken in web app into a report. > > > If you just wanna convert one object in a list string. > > > >

Re: CSV output

2013-09-23 Thread Lachlan Musicman
On 23 September 2013 22:47, Valder Gallo wrote: > Sorry, i really don´t understand why you need this. To mail merge details taken in web app into a report. > If you just wanna convert one object in a list string. > > map(str, object.__dict__.values()) Thanks! Very succinct. L. > > > > > > O

Re: CSV output

2013-09-23 Thread Valder Gallo
Sorry, i really don´t understand why you need this. If you just wanna convert one object in a list string. map(str, object.__dict__.values()) Other projects to export CSV. https://github.com/valdergallo/data-importer https://pypi.python.org/pypi/django-export https://docs.djangoproject.com/en/

CSV output

2013-09-22 Thread Lachlan Musicman
Hola, I'm using a standard view function to retrieve all details about an object: header =[] headers = object._meta.get_all_field_names() row = [] for field in headers: value = getattr(object, field) row.append(value) to collect info on a particular object passed to a

Re: getting csv output (easily)?

2006-01-09 Thread tonemcd
Thanks for the reminder Eric, I found that link a while ago, looked at it again yesterday and came up with this derivation of Adrians' code that works using a query inline; import csv def output(request): response = HttpResponse(mimetype='text/csv') response['Content-Disposition'] = 'atta

Re: getting csv output (easily)?

2006-01-09 Thread Eric Walstad
On Monday 09 January 2006 08:31, tonemcd wrote: > Hi all, > I'm trying to graft additional functionality onto an admin site I have > running and decided that CSV was a good start... > > I have a urlconf that does this; > (r'^CSV/$', 'djangomysql.apps.subjcentre.views.change_list'), > > and the

getting csv output (easily)?

2006-01-09 Thread tonemcd
Hi all, I'm trying to graft additional functionality onto an admin site I have running and decided that CSV was a good start... I have a urlconf that does this; (r'^CSV/$', 'djangomysql.apps.subjcentre.views.change_list'), and the change_list method in 'views' looks like this; def change_li