I have errors raised in the form's clean method (not tied to a field).
我在表单的干净方法中引发了错误(没有绑定到字段)。
How do I display them in the template?
如何在模板中显示它们?
I tried {{ forms.errors }} and {{ form.non_field_errors }} but neither worked.
我尝试了{{forms.errors}}和{{form.non_field_errors}},但都没有奏效。
1 个解决方案
#1
6
According to the docs, they go in a special field (__all__
) and should be accessed via the non_field_errors()
method. At a guess, I'd say that method returns a sequence.
根据文档,它们进入一个特殊字段(__all__),应该通过non_field_errors()方法访问。猜测,我会说该方法返回一个序列。
#1
6
According to the docs, they go in a special field (__all__
) and should be accessed via the non_field_errors()
method. At a guess, I'd say that method returns a sequence.
根据文档,它们进入一个特殊字段(__all__),应该通过non_field_errors()方法访问。猜测,我会说该方法返回一个序列。