Задать вопрос

Тел: +7 965 3737 888

473

Просмотров

2

Ответов

Nice form errors

Nicely output all form errors in one block, using field labels rather than the field attribute names.

Вопрос полезен? Да0/Нет0
file_2835.py(597.0б)
None

Ответы (2):

Ответwhiteinge:18.10.2009
Ответ полезен? Да0/Нет0

Example?

Ответdaemian_mack:10.07.2010
Ответ полезен? Да0/Нет0

Example:

(My line-formatting is going to get wiped out by the Markdown processor, so you'll have to paste this into an editor and do indenting there.)

{% if form.errors %} <ul class="messages"> {% with form|nice_errors as qq %} {% for error_name,desc in qq.items %} <li>{{ error_name }}:</li> <li>{{ desc }}</li> {% endfor %} </ul> {% endwith %} {% endif %}

Since ErrorDict does some auto-HTMLizing of the dict values, this will produce doubly-nested unordered lists.