0

I am having running into an issue using flask framework to generate some html pages using a template (this is my first using Flask or any framework for that matter)

I am calling the template using the usual render_template call

return render_template("index.html", rec_list = rs_rec_list, type_list = rs_type_list)

rs_rec_list and rs_type_list being in the standard python list format

My template then has the following section of code:

<div class = "new_record_column">
    <div class="leftcolumn">
        <div class="new_record_header">
            ADD NEW RECORD
        </div>
        <div class="new_record_container">
             <label for "refnum">Ref No. </label>&nbsp
             <input type="text" id="refnum" size="30"> &nbsp &nbsp
             <select id="rec_type">
                    {% for type_item in type_list %}
                        <option value = loop.index> {{type_item}} </option>
                     {% endfor %}
             </select> &nbsp &nbsp
             <button>GO</button>
        </div>
    </div>
</div>
<table>
     <tr>
        <th>Reference No.</th>
        <th>Header 1</th>
        <th>Header 2</th>
        <th>Type</th>
        <th>Operator</th>
        <th>Comments</th>
        <th>Date/time</th>
     </tr>
     <tr>
      {% for rec_item in rec_list %}
        <td> {{rec_item}} </td>
     {% endfor %}
     </tr>
</table> 

The issue I am having is that the first for loop that populates the select list works as it should, but the second for loop that populates the columns in the table, doesn't seem to do anything. I am pretty sure this is obvious, but I have probably been staring at it too long now to see it :)

1 Answer 1

1

Have you checked if rec_list is empty?

Sign up to request clarification or add additional context in comments.

2 Comments

Funny you should mention it, I was just running some checks, and when I put rec_list in place of type_list it was failing also.
SO now for the stupid part, it turns out I was editing the wrong file to feed rec_list into the template lol. I am testing a Flask to run the server and also wsgiref. I was editing the wsgiref file, but had Flask running....doh! Needless to say everything is running fine now.

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.