I'll quote Massimo here...   
http://permalink.gmane.org/gmane.comp.python.web2py/79516

A field has two attributes, requires and represent. If web2py finds a
'reference auth_user" but no requires, it assumes

db.report.person.requires=IS_IN_DB(db, db.auth_user.id,
db.auth_user._format)
db.report.person.represent = lambda id: db.auth_user._format %
db.auth_user[id]

If you give a custom requires, you also need a custom represent or you
do not get one.

In your case it would be easier to do:

db.auth_user._format = '%(last_name)s'

and use the default ones.




On Saturday, July 21, 2012 7:13:08 AM UTC-7, david.waldrop wrote:
>
> I have a table defined as follows:
>
>      db.define_table('org', 
>          Field('name'), 
>          Field('otype',db.orgtypes, label='Type'),
>          Field('jurisdiction',db.jurisdictions),
>          Field('created_by',db.auth_user,readable=True,writable=False),
>         
>  
> Field('created','datetime',default=request.now,readable=False,writable=False),
>         
>  
> Field('last_activity','datetime',default=request.now,readable=False,writable=False),
>  
>   
>          Field('deletedflag', comment='This flags the record as deleted, 
> but does not remove.', writable=False, readable=False),
>          migrate=migrate_db)      
>      db.org.name.requires = [IS_NOT_EMPTY(),IS_NOT_IN_DB(db, 'org.name')]
>      db.org.otype.requires = IS_IN_DB(db, 'orgtypes.id', '%(name)s', 
> zero=T('choose one'))
>      db.org.jurisdiction.requires = IS_IN_DB(db, 'jurisdictions.id', 
> '%(name)s', zero=T('choose one'))
>      if auth.is_logged_in():
>          db.org.created_by.default = auth.user.id
>
> and am trying to use SQLForm.grid like this - SQLFORM.smartgrid(db.org)
>
> The display shows the name of the create_by field by automatically looking 
> up the id of the user who created the organization record, however neither 
> the jurisdictio field, nor the otype field do the same.  Both display the 
> primary key instead of the appropriate names.  
>
> A second issue that may be related in the actual display of the of the 
> auto-rederenced user is David Waldrop (29) - where 29 is the primary key of 
> the user.  I would like to eliminate this as well as it means nothing to 
> the user.
>
> I have played with represents, but cannot figure out why the behavior 
> seesm inconsistent.  Any suggestions are very much appreciated?
>

-- 



Reply via email to