Python Forum
Passing multiple values from template to template
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Passing multiple values from template to template
#1
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")
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Template Waveform Function does not produce anything after being run amy5678 3 1,816 Nov-30-2020, 12:47 PM
Last Post: jefsummers
  How to make a variable contain multiple values stevenjwilliams83 10 3,553 Apr-30-2020, 07:22 AM
Last Post: pyzyx3qwerty

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020