Python Forum

Full Version: Passing multiple values from template to template
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
What I'm trying to do now is make it so that each result from the search is returned to the user as a clickable link that will go to more details about the book.

I'm currently working on book.html and creating the file. One quick question I think I'll have is : How do I pass the value from search.html (with all the search result info I need) into books.html? I assume I pass it through the template just like I did with search? Do I use the same variable name? Does it matter?


Thanks

PYTHON:

@app.route("/search", methods=["GET", "POST"])
def search():
    search = request.form.get("search")
    searchCombo = search + '%'
    result = db.execute("SELECT * FROM books WHERE author LIKE :search OR isbn LIKE :search OR title LIKE :search LIMIT 20", {'search': searchCombo}).fetchall()
    return render_template("search.html", search=result)


@app.route("/book", methods=["GET", "POST"])
def book():
    return render_template("book.html")