There is no way to do this. When you import the first record, the second does not exist yet therefore the reference cannot be adjusted by web2py. This is why self references are never a good idea. Use a link table instead.
On Sep 25, 2:19 pm, Jurgis Pralgauskis <[email protected]> wrote: > Hello, > > I have Topics Tree like this > > db.define_table("Topics", > Field("parent_id","reference Topics", label=T("Parent > Topic"), > #~ widget=my_hierarchical_options_widget, # probably > overriden by requires > requires=IS_EMPTY_OR(IS_IN_DB(db, > 'Topics.id','Topics.name')) > ), > .... > ) > > after exporting I get > > Topics.id,Topics.parent_id, ... > 10,10,... > 11,10,... > > but after reimporting the first record looses parent_id > I can see by exporting again: > 27,10,... > 28,27,... > > I understand that it should have some hook to update its reference > after it learns it's id. > probably this is not very often way to model sth but is probably a bug > - > > ps.: I was defining "root" topics this way, but I found workaround to > define root's by parent_id=None ;)

