Yes that worked. Kinda weird :)

pet.category.category_name worked.

Thank you very much.

Yanni.

On May 20, 11:06 am, "mr.freeze" <[email protected]> wrote:
> It will do it automatically. You should be able to do:
> pet.category.name
>
> On May 20, 12:58 pm, Yanni <[email protected]> wrote:
>
> > I'm slightly confused as to how to reference a field when I have the
> > foreign key.
>
> > table pets:
> > pets.id
> > name
> > category (foreign key category.id)
> > description
>
> > table category:
> > category.id
> > category_name
>
> > I am trying to show the category name, in my show page/function,
> > instead of a number.
>
> > In the controller, I do a
> > show():
> > id=request.vars.id
> > pet=db(db.pets.id==id).select()
> > return dict(pet=pet[0])
>
> > In the view, among other things, I have {{=pet.category}}
> > Which of course returns a number.
>
> > At which point am I supposed to join the category table and the pet
> > table, to do a lookup for the category name?
> > What does the code for that look like? Does it have to be a join?
>
> > Thank you very much.
> > Yanni.
>
>

Reply via email to