0
'str' Object has no attribute 'contains'
I am trying to create a query using Flask-Sqlalchemy
Flask should return me a list of books according to the user’s search. It selects 4 search options and type in an input to search.
EX: It selects TITLE search and type "Lord" as input.
The query should return all books containing the word Lord in the TITLE.
I have 2 variables
info_type = request.form.get('book_tags')
book_info = request.form.get('search_value').lower()
And the query
Book.query.filter(Book.info_type.contains(book_info).all()
If I replace the variable "info_type" directly with ISBN, TITLE, AUTHOR, YEAR (possible values for the variable info_type) function namespace.
ex:
Book.query.filter(Book.author.contains(book_info).all()
But I need a variable, because there are 4 different types of research.
Can someone give me some idea how to fix this?
Try with
like
to see if it works.– gato