diff --git a/django/newforms/forms.py b/django/newforms/forms.py index 265668bbab1..e0b3d500b5a 100644 --- a/django/newforms/forms.py +++ b/django/newforms/forms.py @@ -84,13 +84,9 @@ class Form(StrAndUnicode): top_errors.extend(['(Hidden field %s) %s' % (name, e) for e in bf_errors]) hidden_fields.append(unicode(bf)) else: - label = bf.label_tag(escape(bf.verbose_name+':')) - if errors_on_separate_row: - if bf_errors: - output.append(error_row % bf_errors) - output.append(normal_row % (label, bf)) - else: - output.append(normal_row % ((bf_errors, label, bf))) + if errors_on_separate_row and bf_errors: + output.append(error_row % bf_errors) + output.append(normal_row % {'errors': bf_errors, 'label': bf.label_tag(escape(bf.verbose_name+':')), 'field': bf}) if top_errors: output.insert(0, error_row % top_errors) if hidden_fields: # Insert any hidden fields in the last row. @@ -105,15 +101,15 @@ class Form(StrAndUnicode): def as_table(self): "Returns this form rendered as HTML s -- excluding the
." - return self._html_output(u'%s%s', u'%s', '', True) + return self._html_output(u'%(label)s%(field)s', u'%s', '', True) def as_ul(self): "Returns this form rendered as HTML
  • s -- excluding the ." - return self._html_output(u'
  • %s%s %s
  • ', u'
  • %s
  • ', '', False) + return self._html_output(u'
  • %(errors)s%(label)s %(field)s
  • ', u'
  • %s
  • ', '', False) def as_p(self): "Returns this form rendered as HTML

    s." - return self._html_output(u'

    %s %s

    ', u'

    %s

    ', '

    ', True) + return self._html_output(u'

    %(label)s %(field)s

    ', u'

    %s

    ', '

    ', True) def non_field_errors(self): """