Search code examples
pythonhtmllistjinja2

Jinja not displaying the values in HTML


I am very new to Python and Jinja and facing an issue in accessing the values of the list in HTML. It is showing blank on the page. Given below is the code snippet, any help would be highly appreciated. The emplList is retrieving the values in the manner [0,"John"] [1,"Sunny"] [2,"Pal"]

app = Flask(__name__)
emplList = pd.read_sql_query("SELECT DISTINCT employee_name FROM employeeTBL", conn)

@app.route('/')
def home():
    return render_template('app.html', employees=emplList)

if __name__=='__main__':
    app.run(debug=True)
    

<select id="multipleSelect" multiple name="native-select" placeholder="Native Select" data-search="true" data-silent-initial-value-set="true">
          {% for row in employees%}
             <option value={{row.employee_name}}>{{row.employee_name}}</option>
          {% endfor %}
</select>

Solution

  • finally able to get past the error, given below is the code that worked

    {% for row in employees.employee_name %}
                 <option value='{{row}}'>{{row}}</option>
    {% endfor %}