how doesn't work?

P.S. you should cache this for speed:

db.car.make.default = db(db.car_makers.name=='Ford').select
(db.car_makers.id,cache=(cache.ram,3600)).first().id

On Jan 24, 9:01 pm, weheh <richard_gor...@verizon.net> wrote:
> Sorry. I was writing off the top of my head. Of course, I did exactly
> what you wrote in my actual code. Still doesn't work.
>
> On Jan 24, 9:53 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > I think you want:
>
> > Field('make',db.car_makers,IS_IN_DB(db,db.car_makers.id,'%(name)s')
>
> > and
>
> > db.car.make.default = db(db.car_makers.name=='Ford').select
> > (db.car_makers.id).first().id
>
> > On Jan 24, 8:46 pm, weheh <richard_gor...@verizon.net> wrote:
>
> > > I'm certain this has been asked a bunch of times. I've spent the last
> > > hour looking for it but can't find it anywhere. Sorry.
>
> > > The question is how to set the default value of a reference field
> > > based on a query of the referenced table.
>
> > > db.define_table('car_makers',Field('name',unique=True))
> > > db.define_table('car',
> > >   Field('make',db.car_makers,IS_IN_DB(db,'car_makers.name','%(name)
> > > s')),
> > >   Field('model'))
>
> > > I want to set db.car.make.default=db(db.car_makers.name=='Ford').select
> > > (db.car_makers.id)[0]
> > > so that when I do an SQLFORM, the drop down list of db.car.make will
> > > pre-select "Ford".
>
> > > This isn't working for me. What am I doing wrong?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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.

Reply via email to