Reputation: 2142
I know I'm doing this the wrong way - how do I do this without a list comprehension but with a query in peewee. I would like to get a query to see if a search term is "in" the objects parameter.
knights = Knight.select()
knights = [knight for knights in knights if request.args.get('ni').lower() in \
knights.who_say.lower() ]
Upvotes: 1
Views: 1189
Reputation: 26245
Look at http://peewee.readthedocs.org/en/latest/peewee/querying.html#column-lookups
A real example might be better I'm not clear what you're trying to do exactly....but it looks like you want the case insensitive 'like'.
ni = request.args.get('ni')
Knights.select().where(Knights.who_say ** ni.join(('%', '%')))
Upvotes: 3