Honza Sedloň Honza Sedloň - 1 year ago 100
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?

Answer Source

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] }}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download