So I've got different columns, and I'm making a search bar to search for different criteria so a user could narrow their search.
my search command:
def search():
search=request.args.get('search')
search='%{}%'.format(search)
games=Game.query.filter(or_(Game.name.like(search),Game.genre.like(search),Game.platform.like(search)))
return render_template('ConsoleGames.html', games=games)
My database model:
class Game(db.Model):
__tablename__='games'
id=db.Column(db.Integer, primary_key=True)
name=db.Column(db.String(64), nullable=False)
genre=db.Column(db.String(64), nullable=False)
description=db.Column(db.String(300), nullable=False)
image=db.Column(db.String(60), nullable=False)
price=db.Column(db.Integer, nullable=False)
platform=db.Column(db.String(64), nullable=False)
consoletype_id=db.Column(db.Integer, db.ForeignKey('consoletype.id'))
Currently, I can only search 1 criteria from 1 column at a time. Trying to do both will give me a blank page. How would I make it so that I could search for multiple criteria from different columns?