[web2py] Re: Self Referential references in models not getting id decoded automatically

2012-02-05 Thread Mark Kirkwood
Ok figured out what was causing that - I had one record with '0' for a sire_id and no dog with id = 0. Fixing that up makes the representation code below work. Yay! *But*... now the edit drop down list is showing id's instead of names... scratches head I'm sure that *was* working before

[web2py] Re: Self Referential references in models not getting id decoded automatically

2012-02-05 Thread DenesL
You could do: def register_dog(): if request.args(0) == 'edit': db.dog.sire_id.requires = IS_IN_DB(db(db.dog.id! =request.args(2)), db.dog, db.dog._format) form=SQLFORM.grid(db.dog, csv=False, paginate=5, user_signature=False) return dict(form=form) On Feb 5, 4:23 am, Mark

[web2py] Re: Self Referential references in models not getting id decoded automatically

2012-02-05 Thread Mark Kirkwood
A simpler fix for the edit/add functions is to specify a format in the model: db.dog.sire_id.requires = IS_EMPTY_OR(IS_IN_DB(db, 'dog.id', '%(name)s')) (Hmm ... suspect I had that there before at some stage which, but edited the format away when I was trying to pin down the other problems -

[web2py] Re: Self Referential references in models not getting id decoded automatically

2012-02-04 Thread Mark Kirkwood
I see that this has been noted as an issue here: http://code.google.com/p/web2py/issues/detail?id=382 I am using 1.99.4, anything I can try? Regards Mark On 05/02/12 13:17, Mark Kirkwood wrote: In order to generate a model with foreign references to itself you need to use 'reference table'

[web2py] Re: Self Referential references in models not getting id decoded automatically

2012-02-04 Thread Mark Kirkwood
It *almost* works using: db.dog.sire_id.represent = lambda sire_id, row: db(db.dog.id==sire_id).select(db.dog.name) However that brings back a header 'dog.name' that mucks up the appearance of the form. What I wanted to write was: db.dog.sire_id.represent = lambda sire_id, row: