1 2 3 4 5 6 7 8 9 10 | {% if form.errors %}
<div id="form-error">
<p>The operation could not be performed because one or more error(s) occurred.<br />Please resubmit the form after making the following changes:</p>
<ul>
{% for field in form %}
<li>{{ field.errors|striptags }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
|
More like this
- Updated version of #31 by ubernostrum 6 years, 2 months ago
- Complex Formsets by smagala 4 years, 4 months ago
- Show all form errors by timbroder 11 months, 1 week ago
- List all errors in a form +bootstrap highlighting by ibrahimlawal 8 months ago
- SnippySnip by youell 4 years, 10 months ago
Comments
replace < li>{{ field.errors|striptags }}< /li>
with: {% if field.errors %}< li>{{ field.errors|striptags }}< /li>{% endif %}
so that fields with no error don't show up as an empty < li> element
p.s. remove the spaces i've put in the li tags, this site doesn't let me paste html! eurgh
#
This is a better one, it shows field name to clarify the "this field is required" message. [HTML_REMOVED] [HTML_REMOVED]The operation could not be performed because one or more error(s) occurred[HTML_REMOVED] [HTML_REMOVED] {% for field,error in form.errors.items %} [HTML_REMOVED]{{field}} - {{ error|striptags }}[HTML_REMOVED] {% endfor %} [HTML_REMOVED] [HTML_REMOVED]
#