Self-reference fields don't get the automatic "requires" and "represent" attributes defined because the referenced table does not yet exist at the time the field is defined (because the field is contained within the table definition, which obviously hasn't completed yet). So, you'll have to manually define the requires and represent attributes after you define the table.
Anthony On Sunday, March 3, 2013 8:03:02 AM UTC-5, 黄祥 wrote: > > hi, > > i want to create category and sub category table using self-reference. > when i create the table it's seems normal (i've checked in sql.log) : > > CREATE TABLE category_archive( > id INTEGER PRIMARY KEY AUTOINCREMENT, > category CHAR(10) NOT NULL UNIQUE, > * parent INTEGER REFERENCES category (id) ON DELETE CASCADE,* > is_active CHAR(1), > created_on TIMESTAMP, > created_by INTEGER REFERENCES auth_user (id) ON DELETE CASCADE, > modified_on TIMESTAMP, > modified_by INTEGER REFERENCES auth_user (id) ON DELETE CASCADE, > current_record INTEGER REFERENCES category (id) ON DELETE CASCADE > ); > > and here is in model : db.py > db.define_table('category', > Field('category', length=10, notnull=True, unique=True), > Field('parent', 'reference category'), > format='%(category)s') > the problem is when i want to fill the form the parent field is not > showing drop down, even in database administration too, is it normal or > there is something wrong in my code? > > note: > i've tried the others table that using reference to another table it's > work fine (showing drop down in form field) > i've tried to copas from book > http://web2py.com/books/default/chapter/29/06#Self-Reference-and-aliases the > result is same too (not showing drop down in form field even in database > administration too) > > thank you very much in advance > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.