I am trying to make another table that uses those values from the
add_product table
ty for the fast reply :-)
here is my sql layout
db.define_table('category',
SQLField('name'),
SQLField('headline',length=512))
db.define_table('add_product',
SQLField('name'),
SQLField('category',db.category, requires=IS_IN_DB(db.category.id,
db.category.name)),
SQLField('description', 'text'),
SQLField('image','upload',default=''),
SQLField('quantity','integer',default=0),
SQLField('price','double',default=1.00))
db.define_table('product',
SQLField('name',db.add_product.name),
SQLField('category',db.category, requires=IS_IN_DB(db.category.id,
db.category.name)),
SQLField('description',db.add_product.description),
SQLField('small_image','upload'),
SQLField('large_image','upload',db.add_product.image),
SQLField('quantity','integer',db.add_product.quantity),
SQLField('price','double',db.add_product.price))
On Sun, Sep 12, 2010 at 2:33 PM, mdipierro <[email protected]> wrote:
> what do you mean by?
>
> SQLField('price','double',db.add_product.price)
>
> I think this should just be
>
> Field('price','double')
>
> and same for the other fields:
>
> db.define_table('product',
> SQLField('name'),
> SQLField('category',db.category,
> requires=IS_IN_DB(db,db.category.id,'%(name)s')),
> SQLField('description'),
> SQLField('small_image','upload'),
> SQLField('large_image','upload'),
> SQLField('quantity','integer'),
> SQLField('price','double'))
>
>
>
> On Sep 12, 4:11 pm, ukolo <[email protected]> wrote:
> > Receiving the following error in my DB Setup and can't figure it out
> >
> > Traceback (most recent call last):
> > File "gluon/restricted.py", line 186, in restricted
> > exec ccode in environment
> > File "/home/www-data/web2py/applications/Working/models/db.py", line
> > 60, in <module>
> > SQLField('price','double',db.add_product.price))
> > File "gluon/sql.py", line 1359, in define_table
> > t._create(migrate=migrate, fake_migrate=fake_migrate)
> > File "gluon/sql.py", line 1716, in _create
> > referenced = field.type[10:].strip()
> > AttributeError: 'Expression' object has no attribute 'strip'
> >
> > this is the table
> >
> > db.define_table('product',
> > SQLField('name',db.add_product.name),
> > SQLField('category',db.category, requires=IS_IN_DB(db.category.id,
> > db.category.name)),
> > SQLField('description',db.add_product.description),
> > SQLField('small_image','upload'),
> > SQLField('large_image','upload',db.add_product.image),
> > SQLField('quantity','integer',db.add_product.quantity),
> > SQLField('price','double',db.add_product.price))
> >
> > Any help would be appreciated
>