Hello everyone, I'm trying to build an app in web2py. The purpose of the
app is to show products of a particular category. In the model i've created
three tables, primary category, last category and products. e.g. the
primary category 'women's fashion' has different last level categories like
'women's dresses' and 'women's watches'. products belong to last level
categories.
db.define_table(
'primary_category',
Field('primary_category_id', 'integer'),
Field('primary_category_name', 'string'),
primarykey=['primary_category_id'],
format='%(primary_category_name)s'
)
db.define_table(
'last_category',
Field('primary_category', db.primary_category),
Field('last_category_id', 'integer'),
Field('last_category_name', 'string'),
Field('new_tree', 'boolean'),
primarykey=['last_category_id'],
format='%(last_category_name)s'
)
db.define_table(
'products',
Field('PrimaryCategory', db.last_category),
Field('SellerName', 'string'),
Field('Name', 'string'),
Field('SellerSku', 'string'),
Field('Color', 'text'),
Field('Gender', 'text'),
Field('MainImage', 'upload'),
primarykey=['SellerSku']
)
when i add an entry to the table last category it gives me an error <class
'sqlite3.IntegrityError'> foreign key constraint failed
can someone guide me what i'm doing wrong
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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 [email protected].
For more options, visit https://groups.google.com/d/optout.