1

So, let's say that I have this list written on my main Flask app:

calculations = ['Summary', 'Average', 'Minimal Value', 'Maximum Value', 'Median', 'Count', 'Standard Deviation']

I have a template which goes like this:

@app.route('/analyze.html')
def analyze():
    return render_template('analyze.html', name=calculations)

And on the template, I wrote:

<select class="form-control" name="calculations">
    {% for calc in calculations %}
        <option value="{{ calc }}">{{ calc }}</option>
    {% endfor %}
</select>

I want to show the calculations list into the select options on the HTML template so it can chooses one of the calculations. When I tried this way, it displayed nothing on the option list.

How should i do this?

1
  • 1
    Don't you mean calculations=calculations? Commented May 21, 2017 at 12:28

1 Answer 1

3

It looks like you're assigning the list to a variable named 'name' in the route. You should change

return render_template('analyze.html', name=calculations)

to be

return render_template('analyze.html', calculations=calculations)
Sign up to request clarification or add additional context in comments.

1 Comment

Omg, I didn't notice it before. This is the kind of error i hate. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.