Hi. Please, explain why you need a separate description table, and why is it referencing product while the same time product references description table. I think something is wrong with the database design. I didn't come across any database that would need this kind of referencing. If you write more about what you want to accomplish, we can help easier. Should this be a many-to-many connection?
You can reference only tables that are defined before the table from where you are creating the reference. regards mmlado On Monday 09 November 2009 14:16:56 David wrote: > Ok so I removed the db. from all the references. I am still getting a > similar error about tables not existing. > > ====== > Traceback (most recent call last): > File "/var/www/web2py/gluon/restricted.py", line 184, in restricted > exec ccode in environment > File "/var/www/web2py/applications/inventory/models/db.py", line 74, > in <module> > Field('review', 'reference review')) > File "/var/www/web2py/gluon/sql.py", line 1195, in define_table > t._create_references() > File "/var/www/web2py/gluon/sql.py", line 1454, in > _create_references > raise SyntaxError, 'Table: table \'%s\'does not exist' % > referenced > SyntaxError: Table: table 'product_description'does not exist > > ===== > > On Nov 9, 6:55 am, Mladen Milankovic <mml...@gmail.com> wrote: > > Hi. > > > > When using reference you don't need the db. part. Only the name of the > > table. > > > > Like: > > Field('description', 'reference product_description'), > > > > It uses the same database as the table you are just creating. > > > > regards > > mmlado > > > > On Monday 09 November 2009 13:51:05 David wrote: > > > So I have the following code and it's not generating tables but > > > perhaps my thinking isn't quite clear on this. I can't link two > > > tables unless one exists previously and that table cannot reference > > > any other table that is not created unless a reference is used.... > > > explain why this gives me "Tables do not exist" errors no matter which > > > order I use... > > > > > > db.define_table('product', > > > Field('date_added', 'datetime'), > > > Field('date_available', 'datetime'), > > > Field('name', length=55), > > > Field('quantity', 'integer'), > > > Field('price', length=10), > > > Field('description', 'reference db.product_description'), > > > Field('image', 'reference db.image'), > > > Field('review', 'reference db.review')) > > > > > > db.define_table('image', > > > Field('product_id', 'reference db.product'), > > > Field('name'), > > > Field('file', 'upload')) > > > > > > db.define_table('product_description', > > > Field('prduct_id', 'reference db.product'), > > > Field('description', 'text')) > > > > > > db.define_table('review', > > > Field('product_id', 'reference db.product'), > > > Field('rating'), > > > Field('review', 'text')) > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@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 -~----------~----~----~----~------~----~------~--~---