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>
2
Answers
finally able to get past the error, given below is the code that worked
Edit: This should be exactly what you need based on the pandas docs and how jinja expects template data:
If this isn’t working for you, feel free to comment on my answer here or edit your question to provide more detailed info on what your data is or problems you’re having.