Virtual Fields in auth_user?

61 views
Skip to first unread message

Fabiano Almeida

unread,
Jul 9, 2014, 2:14:14 PM7/9/14
to web...@googlegroups.com
Hi again,

It's possible insert virtual field in auth_user? how?

thanks,

Fabiano.

Massimo Di Pierro

unread,
Jul 10, 2014, 2:55:03 AM7/10/14
to web...@googlegroups.com
auth.settings.extra_fields['auth_user'] = [Field.Virtual(....), ... ]

Fabiano Almeida

unread,
Jul 10, 2014, 8:26:01 AM7/10/14
to web...@googlegroups.com
Hi Massimo,

I tried this:

auth.settings.extra_fields['auth_user']= [
        ...
        Field('dept_grid', compute = lambda row: Departamento[row['departamento_id']].nome if row['departamento_id'] else None, label = 'Departamento'),
        Field.Virtual('dept_name', lambda row: Departamento[row.departamento_id].nome if row.departamento_id else None, label = 'Departamento')]

The compute field work, the virtual field does not work. And the error by calling the table in SQLFORM.grid:
AttributeError: 'Row' object has no attribute 'dept_name'

Can I use virtual field to display information from another table?

Thanks,

Fabiano.


--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tim Korb

unread,
Aug 30, 2014, 10:51:30 AM8/30/14
to web...@googlegroups.com
Did you ever get this working?  I tried the same thing, adding

        Field.Virtual('last_first', lambda row: "%s, %s" % (row.auth_user.last_name, row.auth_user.first_name))

to auth.settings.extra_fields['auth_user'], but get the same error message when trying to build the SQLFORM.grid.

Tim
Reply all
Reply to author
Forward
0 new messages