当我试图在Jinja2模板中写入来自wtforms的错误时,它会返回未解码的引号。我该如何修复它?
{% if registrationForm.errors %}
<script></script>
{% endif %}
错误等同于
{'email': ['This field is required.'], 'username': ['This field is required.'], 'acceptTOS': ['This field is required.'], 'csrf_token': ['CSRF token missing'], 'password': ['This field is required.']}
<script>swal("Error!", "{% for error in registrationForm.errors.keys() %}[{{ error }}] {{ registrationForm.errors[error][0] }}\n{% endfor %}", "error")</script>
解决了更多的问题。 - Honza Sedloň