Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Formatting django form.non_field_errors in a template

How do I format django form.non_field_errors.as_text in a template without them being either an unordered list or having an * appended to the front?

{{ form.non_field_errors.as_text }} displays the errors with an * in front of the text.

This django ticket was also helpful in explaining why the * will not be removed, but that doesn't help me. I do not want the *.

Both {{ form.non_field_errors }} and {{ form.non_field_errors.as_ul }} display as an unordered list, and I do not want an unordered list.

like image 499
nu everest Avatar asked Mar 16 '13 16:03

nu everest


1 Answers

{% for error in form.non_field_errors %}
    {{error}}
{% endfor %}

When you call the list of errors as text it will try to display it as a list. Simply loop through the list to get the error by itself so you can apply your own styling.

More info about it on the django project website

like image 90
Matt Camilli Avatar answered Nov 10 '22 03:11

Matt Camilli