Honza Sedloň Honza Sedloň - 2 months ago 8x
Python Question

Displaying Flask-WTF error shows extra characters

I want to display an error from a field in my Flask-WTF form with JavaScript. Printing out

['This field is required']
, but I don't want
in the output. How do I display the error in the right format?


Each field can have multiple errors, so they are always contained in a list, even if there is only one error. There is nothing special about Jinja or Flask-WTF here, you just need to pay attention to the data you're working with.

{{ form.password.errors[0] }}
{{ form.errors['password'][0] }}