42👍
✅
Form errors in Django are implemented as an ErrorDict
instance (which is just a subclass of dict
with extras). Try a slight adjustment to your template for loop syntax:
{% for key, value in form.errors.items %}
19👍
Are you, by any chance, looking for form.non_field_errors
? That is how you would get access to the errors that aren’t associated with a particular field.
{% if form.non_field_errors %}
<ul>
{{ form.non_field_errors.as_ul }}
</ul>
{% endif %}
Check the forms.py test suite as well for another example. Search for form.non_field_errors
Source:stackexchange.com