All the functions in the following code works as accordingly, with school returning the correct output. However, when school is passed into the html code and onto the jinja2 for loop, all the dropdown items have identical values although it displays unique school names at user end. How to make the values unique such that the form for the html will return the correct values?
def schools():
conn = sqlite3.connect("schools.db")
cur = conn.cursor()
cur.execute("SELECT DISTINCT Name FROM schools ORDER BY Name ASC")
rows = cur.fetchall()
schools = []
for row in rows:
schools.append(row[0])
conn.close()
return schools
def home():
school = schools()
print(school)
return render_template('home.html', schools = school)
<input list= "schools" ,name = "school">
<datalist id = "schools">
<select name = "school">
{% for school in schools%}
<option value = "{{school}}">
{% endfor %}
</select>
</datalist>