Hi, Didn't worked, maybe I missing something or do some error! this is my real model, with te last line added as suggested is it correct?
thank you Carlos Aboim # coding: utf8 import datetime now = datetime.datetime.now() registos=SQLDB("sqlite://registos.db") registos.define_table('cliente', SQLField('nome', 'string'), SQLField('contacto', 'string'), SQLField('email'), SQLField('morada', 'string', length=100)) registos.define_table('obra', SQLField('numero', 'integer'), SQLField('nome', 'string'), SQLField('descricao', 'text', label='Descrição'), SQLField('quantidade', 'integer'), SQLField('cliente', registos.cliente), SQLField('vendedor', default='Rujoca'), SQLField('entrada', 'date', default=now), SQLField('entrega', 'date'), SQLField('preview', 'upload',)) registos.cliente.email.requires = IS_NULL_OR(IS_EMAIL()) registos.obra.numero.requires = [IS_INT_IN_RANGE(5000, 50000),IS_NOT_IN_DB(registos, 'obra.numero'), IS_NOT_EMPTY()] registos.obra.nome.requires = IS_NOT_EMPTY() registos.obra.descricao.requires = IS_NOT_EMPTY() registos.obra.cliente.requires = IS_IN_DB(registos, registos.cliente.id, registos.cliente.nome) registos.obra.vendedor.requires = IS_IN_SET(['João Luís', 'Luís Bilro', 'Luís Pereira', 'Paulo Gonçalves', 'Vítor Silva', 'Rujoca', 'Dacor']) registos.obra.entrega.requires = IS_NOT_EMPTY() registos.obra.preview.comment = 'Utilize ficheiros em formato .jpeg de preferência' registos.obra.cliente.represent = lambda cliente: registos.cliente[cliente].nome 2009/8/14 mdipierro <mdipie...@cs.depaul.edu> > > db.dogs.owner_id.represent=lambda owner_id: db.users[owner_id].name > > On Aug 14, 9:59 am, Carlos Aboim <abo...@gmail.com> wrote: > > Hi folks! > > I am here again as promised. (just kidding) > > > > I whould like to know how to access a cross reference model name. > > For example to clarify, > > I got: > > > > db.define_table('users', > > Field('name'), > > Field('email')) > > > > # ONE (users) TO MANY (dogs) > > db.define_table('dogs', > > Field('owner_id',db.users), > > Field('name'), > > Field('type'), > > Field('vaccinated','boolean',default=False), > > Field('picture','upload',default='')) > > > > And I want to render the 'owner' field of the 'dogs' table with the > > 'name' from 'users' table > > or better dogs.owner = users.name > > > > I'm just getting the _id of that field (integer) > > > > Can I do this?? > > > > Thank you > > Carlos Aboim > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---