From 553a20075e6991e7a60baee51ea68c8adc520d9a Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Sat, 23 Jun 2007 06:19:26 +0000 Subject: [PATCH] Fixed #4527 -- Changed the way errors are displayed in Form.as_p() to avoid invalid XHTML constructs. Based on a patch from SmileyChris. git-svn-id: http://code.djangoproject.com/svn/django/trunk@5518 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/newforms/forms.py | 2 +- tests/regressiontests/forms/tests.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/django/newforms/forms.py b/django/newforms/forms.py index 6ebebded4b9..1ea1c73d9a5 100644 --- a/django/newforms/forms.py +++ b/django/newforms/forms.py @@ -159,7 +159,7 @@ class BaseForm(StrAndUnicode): def as_p(self): "Returns this form rendered as HTML

s." - return self._html_output(u'

%(label)s %(field)s%(help_text)s

', u'

%s

', '

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

%(label)s %(field)s%(help_text)s

', u'%s', '

', u' %s', True) def non_field_errors(self): """ diff --git a/tests/regressiontests/forms/tests.py b/tests/regressiontests/forms/tests.py index d487ab9e8ed..0808ebe97e9 100644 --- a/tests/regressiontests/forms/tests.py +++ b/tests/regressiontests/forms/tests.py @@ -1974,11 +1974,11 @@ AttributeError: 'Person' object has no attribute 'cleaned_data'
  • >>> print p.as_p() -

    +

    -

    +

    -

    +

    If you don't pass any values to the Form's __init__(), or if you pass None, @@ -2684,7 +2684,7 @@ its field's order in the form.
  • Last name:
  • Birthday:
  • >>> print p.as_p() -

    +

    First name:

    Last name:

    Birthday: