my problem is this, the thing is that I have a table with subjects such as algebra, calculus, etc and I have to make the user choose one of these but I don't know how to get all the names from the table to pass it to a list and send it to html to after that show a radio type input and choose one of the subjects.
flask code:
@app.route('/evaluacion', methods=['GET', 'POST'])
def evaluacion():
if request.method == 'POST':
asignatura = request.form['materia']
return redirect( url_for('profesor', asignatura=asignatura ))
ramos = Asignatura.query.filter_by().all()
return render_template('ramos.html', ramos = ramos )
HTML code:
<form action="http://localhost:5000/evaluacion">
{% for {name} in ramos %}
name <input type="radio" name="asignatura" value="{{ name }}">
{% endfor %}
</form>
The truth is that I don't know if the html part is right either, since I'm a complete noob on the subject. Thanks in advance.
In this code segment
The variable "name" is a dictionary with the properties of your table in the database, so to assign the name of the signature as the value of the radius and assuming that this property of the table has the name name then you must change the value of this:
to this:
and to display the subject name next to the radius you should change your HTML from this:
to this: