You are dernormalizing in a link table. Not a good idea. Let's go it b the book:
with crud.create(db.familia_riesgo) The models are like: db.define_table('familia',Field('ficha','string'),format='%(ficha)s') db.define_table('riesgo',Field('nombre','string'),format='%(nombre)s') db.define_table('familia_riesgo', Field('familia_id',db.familia), Field('riesgo_id',db.risiego) ) # this is not necessary # db.familia_riesgo.familia_id.requires=IS_IN_DB(db,'familia.ficha') # this is one way to do it db.familia_riesgo.riesgo_id.requires=IS_IN_DB(db,'riesgo.id','% (nobre)s', _and=IS_NOT_IN_DB(db(db.familia_riesgo.familia_id==request.vars.familia_id),'familia_riesgo.riesgo_id')) On Jul 29, 9:17 am, web2py noob <web2py.n...@gmail.com> wrote: > what can I do for that? > > thanks in advance > > On 29 jul, 09:37, web2py noob <web2py.n...@gmail.com> wrote: > > > On 29 jul, 09:20, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > It depends on how you insert records in familia_risiego > > > with crud.create(db.familia_riesgo) > > > The models are like: > > > db.define_table('familia',Field('ficha','string')) > > > db.define_table('riesgo',Field('nombre','string')) > > > db.define_table('familia_riesgo', > > Field('familia_id','string'), > > Field('riesgo_id','string') > > ) > > > db.familia_riesgo.familia_id.requires=IS_IN_DB(db,'familia.ficha') > > > # I'm tryied this, but don't work; just block the insert if riesgo_id > > repeats even with a different familia_id > > db.familia_riesgo.riesgo_id.requires=IS_IN_DB(db,'riesgo.nombre')),IS_NOT_IN_DB(db,'familia_riesgo.riesgo_id') > > > Regards.