You can change the label text at runtime.
@app.route("/") def hello_world(): _form = RateMovieForm() # Assign your label text at runtime _value = "101010" _form.rating.label.text = f"Your rating out of 10 e.g. {_value}" return render_template('hello.html', form=_form)
Example code showing html output of label and input elements:
from wtforms.fields import FloatField from wtforms.form import Form class TestForm(Form): rating = FloatField(label="Your rating out of 10 e.g.") def test_form(): _form = TestForm() _label = _form.rating.label() # get the generated label html _input = _form.rating() # get the generated input html print(_label) print(_input) # Assign your label text at runtime, _value = "101010" _form.rating.label.text = f"Your rating out of 10 e.g. {_value}" _label = _form.rating.label() # get the generated label html _input = _form.rating() # get the generated input html print(_label) print(_input) if __name__ == "__main__": test_form()