Note that there are some explanatory texts on larger screens.

plurals
  1. POFlask url_for() with multiple parameters
    primarykey
    data
    text
    <h3>The Problem:</h3> <p>I have an a input button in a form that when its submitted should redirect two parameters , <code>search_val</code> and <code>i</code>, to a <code>more_results()</code> function, (listed below), but I get a type error when wsgi builds. </p> <p>The error is: <code>TypeError: more_results() takes exactly 2 arguments (1 given)</code></p> <p>html:</p> <pre><code> &lt;form action="{{ url_for('more_results', past_val=search_val, ind=i ) }}" method=post&gt; &lt;input id='next_hutch' type=submit value="Get the next Hunch!" name='action'&gt; &lt;/form&gt; </code></pre> <p>flask function:</p> <pre><code>@app.route('/results/more_&lt;past_val&gt;_hunches', methods=['POST']) def more_results(past_val, ind): if request.form["action"] == "Get the next Hunch!": ind += 1 queried_resturants = hf.find_lunch(past_val) #method to generate a list queried_resturants = queried_resturants[ind] return render_template( 'show_entries.html', queried_resturants=queried_resturants, search_val=past_val, i=ind ) </code></pre> <p>Any idea on how to get past the build error? </p> <h3>What I've tried:</h3> <p><a href="https://stackoverflow.com/questions/11124940/creating-link-to-an-url-of-flask-app-in-jinja2-template">Creating link to an url of Flask app in jinja2 template</a></p> <p>for using multiple paramters with url_for()</p> <p><a href="https://stackoverflow.com/questions/9023488/build-error-with-variables-and-url-for-in-flask?rq=1">Build error with variables and url_for in Flask</a></p> <p>similar build erros</p> <p>As side note, the purpose of the function is to iterate through a list when someone hits a "next page" button. I'm passing the variable <code>i</code> so I can have a reference to keep incrementing through the list. Is there a flask / jinja 2 method that would work better? I've looked into the cycling_list feature but it doesn't seem to able to be used to render a page and then re-render it with <code>cycling_list.next()</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload