Hi Matt, two issues
1)
db.person.catname.requires=[IS_NOT_EMPTY(), IS_IN_DB
(db,'kindofcontact.id','%(catname)s')]
should be if you want a dropbox.
db.person.catname.requires=IS_IN_DB(db,'kindofcontact.id','%
(catname)s')
2) the error you are getting is very strange. Your database seems to
return 'ANZN' for a field that is supposed to be integer.
Are you sure person.catname is a referece to kindofcontact.id?
If not and you are actually trying to store the kindofcontact.catname
in person.catname than this should be
db.person.catname.requires=IS_IN_DB(db,'kindofcontact.catname')
Massimo
On Dec 22, 6:30 am, mattvangerwen <[email protected]> wrote:
> Hi,
>
> I'm new to web2py. Even though I like to have postgresl as database.
> For a crm application and later on for an casemanager application, I
> like to several category-tables. For example a person can have
> multiple phone-numbers for different companies. In SQLite it is
> possible to select a value by name instead by id-number. However this
> does not work with a Postgresql database, with the following statement
> I get an error
> db.person.catname.requires=[IS_NOT_EMPTY(), IS_IN_DB
> (db,'kindofcontact.id','%(catname)s')]
>
> The error is:
> What should I do to solve this?
>
> Traceback (most recent call last):
> File "/idata/development/web2py/gluon/restricted.py", line 62, in
> restricted
> exec ccode in environment
> File "/idata/development/web2py/applications/webCRM/controllers/
> appadmin.py", line 196, in <module>
> File "/idata/development/web2py/gluon/globals.py", line 55, in
> <lambda>
> self._caller=lambda f: f()
> File "/idata/development/web2py/applications/webCRM/controllers/
> appadmin.py", line 53, in insert
> if form.accepts(request.vars,session):
> File "/idata/development/web2py/gluon/sqlhtml.py", line 172, in
> accepts
> ret=FORM.accepts(self,vars,session,formname,keepvalues)
> File "/idata/development/web2py/gluon/html.py", line 490, in accepts
> status=self._traverse(status)
> File "/idata/development/web2py/gluon/html.py", line 136, in
> _traverse
> newstatus=c._traverse(status) and newstatus
> File "/idata/development/web2py/gluon/html.py", line 136, in
> _traverse
> newstatus=c._traverse(status) and newstatus
> File "/idata/development/web2py/gluon/html.py", line 136, in
> _traverse
> newstatus=c._traverse(status) and newstatus
> File "/idata/development/web2py/gluon/html.py", line 136, in
> _traverse
> newstatus=c._traverse(status) and newstatus
> File "/idata/development/web2py/gluon/html.py", line 139, in
> _traverse
> newstatus=self._validate()
> File "/idata/development/web2py/gluon/html.py", line 366, in
> _validate
> value,errors=validator(value)
> File "/idata/development/web2py/gluon/validators.py", line 160, in
> __call__
> if len(self.dbset(field==value).select(limitby=(0,1))):
> File "/idata/development/web2py/gluon/sql.py", line 922, in __eq__
> def __eq__(self,value): return SQLQuery(self,'=',value)
> File "/idata/development/web2py/gluon/sql.py", line 1065, in
> __init__
> right=sql_represent(right,left.type,left._db._dbname)
> File "/idata/development/web2py/gluon/sql.py", line 261, in
> sql_represent
> if fieldtype[0]=='i': return str(int(obj))
> ValueError: invalid literal for int() with base 10: 'ANZN'
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---