I did a search on this error message and everything I saw said that there
is some invalid data in the database (ie - the data doesn't match the
schema).
On Tuesday, December 4, 2012 6:34:00 AM UTC-7, Rakesh Singh wrote:
>
> Hi,
>
> I am having an issue querying a referenced column using the smartgrid
> search widget.
>
> Let's say I have a table defined as follows:
>
> db.define_table('countries',
> Field('country_name', 'string', unique=True, required=True),
> format='%(country_name)s')
>
> Data
> 1 Austria
> 2 Brazil
> 5 China etc.
>
> The second table is as follows:
>
> db.define_table('users',
> Field('user_name', 'string'),
> Field('country', db.countries))
>
> db.users.country.writeable = False
>
>
> The controller is as follows:
>
> def user_list():
> grid = SQLFORM.smartgrid(db.users, linked_tables=['db.countries'])
> return dict(grid=grid)
>
>
> Using the grid search function, click on the Search field, and select
> Country from the drop down field.
> Choose = 'China' and Add.
> This will result in an error. You would have to search for the numeric ID,
> 5 in this case.
> (Incidentally, the same will occur if you choose ID form the dropdown, but
> search for a string instead of a numeric')
> <type 'exceptions.ValueError'> invalid literal for int() with base 10:
> 'BOT' So the question is :
> - As in the example, what is the correct way to search for all users from
> China?
> - Any way to prevent an error if a user enters a string where a numeric is
> expected in the search?
>
> NB. I typed in the above code directly into the email, so there may be
> typos.
>
> Thanks a lot.
>
> Regards,
>
> Rakesh
>
>
>
>
--