Я использую flask и хочу создать панель поиска. Но я не могу. Что мне делать. Вот коды:
Model.py
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_login import LoginManager, UserMixin
from datetime import timedelta
import flask_whooshalchemy
app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///database.db"
db = SQLAlchemy(app)
class Products(db.Model):
__searchable__ = ["product_name"]
id = db.Column(db.Integer, primary_key=True)
product_name = db.Column(db.String(120))
product_amount = db.Column(db.Integer)
product_price = db.Column(db.Float)
app.py
@app.route("/search")
@login_required
def search():
products = Products.query.search(request.args.get("search"))
return render_template("product.html", products=products)
product. html
<form method="GET" action="{{ url_for('search') }}">
<input type="text" name = "search" class="form-control mb-4 w-25 float-right"
placeholder="Search...">
</form>