开发者

How can I list all form related errors in Django?

Is there a direct way of listing out all form errors in Django templates. I'd like to list out both field and non-field errors and any other form errors.

I've found out how to do this on a per-field basis but as said earlier, I'd like to list out everything.

The method I'm using doesn't seem to list out everything.

{% for error in form.errors %}
{{ e开发者_运维知识库rror|escape }}
{% endfor %}

Thanks.


You could loop over all the field in addition to non-field errors:

  • http://docs.djangoproject.com/en/dev/topics/forms/#looping-over-the-form-s-fields
  • Short Django snippet: List all Form Errors
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜