Thanks Anthony,
It works (both solutions) in the grid but not in the edit/new forms you get
when clicking on the auth_memebership link in the grid (the id still
appended to the name/role. May be it is OK as you mentioned regarding
uniqueness.

Best Regards
Itamar Cohen
Picatek
Ahornvej 27
DK-7700 Thisted
Denmark
www.picatek.dk
[email protected]
T: +45 97 91 07 82
M:+45 29 89 07 82

On 22 August 2015 at 17:33, Anthony <[email protected]> wrote:

> By default, the "represent" attribute of a reference field is based on the
> "format" attribute of the table it references. So, you have two options --
> you could either change the "format" attributes of the auth_user and
> auth_group tables:
>
> db.auth_user._format = '%(first_name)s %(last_name)s'  # notice the "id"
> field is excluded
>
> or you could directly change the "represent" attributes of the
> auth_membership.user_id and auth_membership.group_id fields:
>
> db.auth_membership.user_id.represent = lambda id, row: '%(first_name)s
> %(last_name)s' % db.auth_user(id)
>
> Note, if you exclude the "id" field from the representation, two users
> with the same name will appear identically in the list (that's why the
> default representation includes the "id" -- in order to ensure a unique set
> of values).
>
> Anthony
>
> On Saturday, August 22, 2015 at 7:11:12 AM UTC-4, icodk wrote:
>>
>> I made a form for editing  the auth_membership table using smart grid, it
>> works fine.
>> The only issue I have is that the id of the user_id and the id of the
>> group_id are appended to the user name and to the group name.
>> How can I get rid of this 'extra' addition ?
>> For example the user John Smith is shown as: John Smith(15) both in the
>> create/edit and in the grid
>> The group named Teachers is shown as Teachers(4)
>>
> --
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/rgtfBjm_S38/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to