On Wed, Oct 14, 2009 at 4:44 PM, Giedrius <[email protected]> wrote:

>
> How i can make recursive one to many relation? I want to have
> generalized categories like: Programing langauge / High level /
> Python, Programing langauge / Low level / C, Programing langauge /
> High level / PHP, Programing langauge / Low level / ASM and so on..
> I tried to like this, but got an error:
>
> db.define_table('category',
>                Field('name'),
>                Field('parent_id', db.category),
>                Field('info'))
>

To do self-reference or forward reference, use this form:

                 Field('parent_id', 'reference category'),


You can find more about this in section 6.13 of the Manual, "Self-Reference
and Aliases"
( http://www.web2py.com/examples/default/docs )

- Yarko


>
>
> Traceback (most recent call last):
>  File "/home/giedrius/web2py/gluon/restricted.py", line 178, in
> restricted
>    exec ccode in environment
>  File "/home/giedrius/web2py/applications/shop/models/db.py", line
> 74, in <module>
>    Field('parent_id', db.category),
>  File "/home/giedrius/web2py/gluon/sql.py", line 537, in __getattr__
>    return dict.__getitem__(self,key)
> KeyError: 'category'
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to