Yes thanks Dave - a complete beginner's error! I really appreciate you
pointing it out as I have been tearing my hair out today trying to work out
the problem.
thanks again,
Heather
On Monday, 7 September 2015 21:55:17 UTC+1, Heather Dawe wrote:
>
> Hello there,
>
> I am new to web2py - it is a brilliant framework thank you. I am running
> the latest version, defining my models and encountering this error when
> attempting to add a record to a table that defines a many-to-many
> relationship - when I attempt to add a record to table
> ModelInstanceDataItemValue (listed in the model code below). I have
> searched for solutions and can't find any. This may well be a beginner's
> problem but I can't see why it is throwing up the error.
>
> With thanks and best wishes,
> Heather
>
> db = DAL("postgres://heather:secret@localhost:5432/indyfabdb",migrate=True)
>
> db.define_table('ItemType',
> Field('type'),
> Field('description'),
> format='%(type)s')
>
> db.ItemType.type.requires = IS_NOT_IN_DB(db, db.ItemType.type)
> db.ItemType.type.requires = IS_NOT_EMPTY()
>
> db.define_table('DataItem',
> Field('name'),
> Field('type', 'reference ItemType'),
> format='%(name)s')
>
> db.DataItem.name.requires = IS_NOT_IN_DB(db, db.DataItem.name)
> db.DataItem.name.requires = IS_NOT_EMPTY()
>
> db.define_table('DataSet',
> Field('name'),
> Field('location'),
> format='%(name)s')
>
> db.DataSet.name.requires = IS_NOT_EMPTY()
> db.DataSet.name.requires = IS_NOT_IN_DB(db, db.DataSet.name)
> db.DataSet.location.requires = IS_NOT_EMPTY()
>
> db.define_table('DataSetItem',
> Field('DataSetName', 'reference DataSet'),
> Field('DataItemName', 'reference DataItem'),
> Field('position'))
>
> db.DataSetItem.position.requires = IS_NOT_EMPTY()
>
> db.define_table('DataSetValidValue',
> Field('name'),
> Field('DataSet', 'reference DataSet'),
> Field('query', 'text'),
> format='%(name)s')
>
> db.DataSetValidValue.name.requires = IS_NOT_EMPTY()
> db.DataSetValidValue.query.requires = IS_NOT_EMPTY()
>
> db.define_table('ModelType',
> Field('type'),
> Field('description'),
> format='%(type)s')
>
> db.define_table('ModelInstance',
> Field('name'),
> Field('ModelType', 'reference ModelType'),
> format='%name)s')
>
> db.ModelInstance.name.requires = IS_NOT_EMPTY()
>
> db.define_table('ModelInstanceDataItemValue',
> Field('ModelInstance', 'reference ModelInstance'),
> Field('DataItem', 'reference DataItem'),
> Field('value'))
>
> db.ModelInstanceDataItemValue.value.requires = IS_NOT_EMPTY()
>
--
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.