从django中删除会形成验证错误(removing from django forms validation errors)
在Django中,{{form.field.errors}}给出了字段的验证错误。 但它始终将其显示为无序列表()。 但我只是想要错误信息。 有没有办法得到错误信息?
In Django the {{ form.field.errors }} gives the validation error for a field. But it always displays it as unordered list (). But I just want the error message. Is there a way to get the error message?
最满意答案
{% for error in field.errors %}使用{% for error in field.errors %}然后逐个输出每个错误,这将只生成包含消息的字符串而不是无序列表。 文档解释了这个:
http://docs.djangoproject.com/en/1.0/topics/forms/
Use {% for error in field.errors %} and then output each error one by one, this will produce just the string containing the message rather than an unordered list. The docs explain this:
http://docs.djangoproject.com/en/1.0/topics/forms/
更多推荐
发布评论