You can do
headers=dict([(c,db[c.split('.')[0]][c.split('.')[1]].label) for c in
rows.colnames])
SQLTABLE(rows, headers=headers)
Not there is a reason this is not done by default:
- rows may be a result of a joins (thus two columns may end up with
the same name)
- rows may contain an aggregate (and the first line above will fail).
Massimo
On May 18, 10:21 am, Timmie <[email protected]> wrote:
> Hello,
> how can I automatically use the default labels of database fiels
> (defined in db.py) as table headers?
>
> As such:
> SQLTABLE(rows_obj, headers=default_labels)
>
> * Why would web2py not automaticaly use the lables defined in db.py
>
> I tried:
> headers = {}
> for col in mydb.colnames:
> headers.update({mydb._db[tbl][fld] : mydb._db[tbl][fld].label})
>
> But without success.
>
> Thanks,
> Timmie
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---