How errors are displayed , .
reusable template, .
table_form.html:
<table>
{% for error in form.non_field_errors %}
<tr><td>{{ error }}</td></tr>
{% endfor %}
{% for field in form %}
{% for error in form.username.errors %}
<tr><td>{{ error }}</td></tr>
{% endfor %}
<tr><th>{{ field.label_tag }}:</th><td>{{ field }}</td></td>
{% endfor %}
</table>
template.html:
<form>
{% include 'table_form.html' %}
</form>
, . , form1 form2:
template.html:
<form>
{% include 'table_form.html with form=form1 %}
</form>
<form>
{% include 'table_form.html with form=form2 %}
</form>
as_table , BaseForm:
210 def as_table(self):
211 "Returns this form rendered as HTML <tr>s -- excluding the <table></table>."
212 return self._html_output(
213 normal_row = u'<tr%(html_class_attr)s><th>%(label)s</th><td>%(errors)s%(field)s%(help_text)s</td></tr>',
214 error_row = u'<tr><td colspan="2">%s</td></tr>',
215 row_ender = u'</td></tr>',
216 help_text_html = u'<br /><span class="helptext">%s</span>',
217 errors_on_separate_row = False)
{{form.as_table}}