if test0 != None and type(test0) == str:
query = (db.test1.test0 == test0)
elif test0 != None and type(test0) == list:
query = (db.test1.test0.belongs(test0) )
else:
query = (db.test1.id > 0)
return error traceback when access
http://127.0.0.1:8000/a/default/test1?test0=None#
*ValueError: invalid
shouldn't this be:
if test0 != None and type(test0) == str:
query = (db.test1.test0 == test0)
elif test0 != None and type(test0) == list:
query = (db.test1.test0.belongs(test0) )
else:
query = (db.test1.id > 0)
On Saturday, 29 July 2017 02:27:41 UTC-5, 黄祥 wrote:
>
> thx 4 the way out massimo, ano
thx 4 the way out massimo, another way is to use if condition that check
the data type
*e.g.*
if test0 != 'None' and type(test0) == 'str':
query = (db.test1.test0 == test0)
elif test0 != 'None' and type(test0) == 'list':
query = (db.test1.test0.belongs(test0) )
else:
query = (db.test1.id > 0)
tha
if not isinstance(test0, (tuple, list)): test0 = [test0]
query = (db.test1.test0.belongs(test0) )
On Friday, 28 July 2017 20:31:25 UTC-5, 黄祥 wrote:
>
> is it possible belongs to handle if there is only one value?
> e.g.
> *models/db.py*
> db.define_table('test0',
> Field('name'),
> format = '%(n
4 matches
Mail list logo