July 2019
Beginner to intermediate
302 pages
9h 38m
English
The following is a method that searches in our catalog application for name, price, company, and category. We can search for any one criterion, or multiple criteria (except for the last search on category, which can only be searched alone). Notice that we have different expressions for different values. For a float value in price, we can search for equality, and in the case of a string, we can search using like. Also, carefully note how join is implemented in the case of category. Place this method in the views file, that is, flask_catalog_template/my_app/catalog/views.py:
from sqlalchemy.orm.util import join @catalog.route('/product-search') @catalog.route('/product-search/<int:page>') def product_search(page=1): name = request.args.get('name') ...