From 75516392b8bc93ae80a9faeb58d8d9cb5298be9d Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Thu, 16 Nov 2006 01:16:33 +0000 Subject: newforms: Fixed #3027 -- Changed Form as_table(), as_ul(), as_table_with_errors() and as_ul_with_errors() to exclude and
-
First name:
Last name:
Birthday:
>>> print p.as_table() - -
First name:
Last name:
Birthday:
>>> print p.as_ul() - >>> print p.as_table_with_errors() - -
  • This field is required.
First name:
  • This field is required.
Last name:
  • This field is required.
Birthday:
>>> print p.as_ul_with_errors() - >>> p = Person({'first_name': u'John', 'last_name': u'Lennon', 'birthday': u'1940-10-9'}) >>> p.errors() @@ -937,11 +927,9 @@ u'' >>> print p - -
First name:
Last name:
Birthday:
>>> p = Person({'last_name': u'Lennon'}) >>> p.errors() @@ -978,31 +966,25 @@ If it's a string that contains '%s', Django will use that as a format string into which the field's name will be inserted. >>> p = Person(auto_id='id_%s') >>> print p.as_ul() - If auto_id is any True value whose str() does not contain '%s', the "id" attribute will be the name of the field. >>> p = Person(auto_id=True) >>> print p.as_ul() - If auto_id is any False value, an "id" attribute won't be output unless it was manually entered. >>> p = Person(auto_id=False) >>> print p.as_ul() - In this example, auto_id is False, but the "id" attribute for the "first_name" field is given. @@ -1012,21 +994,17 @@ field is given. ... birthday = DateField() >>> p = PersonNew(auto_id=False) >>> print p.as_ul() - If the "id" attribute is specified in the Form and auto_id is True, the "id" attribute in the Form gets precedence. >>> p = PersonNew(auto_id=True) >>> print p.as_ul() - >>> class SignupForm(Form): ... email = EmailField() @@ -1158,36 +1136,28 @@ Form.clean() still needs to return a dictionary of all clean data: ... return self.clean_data >>> f = UserRegistration() >>> print f.as_table() - -
Username:
Password1:
Password2:
>>> f.errors() {'username': [u'This field is required.'], 'password1': [u'This field is required.'], 'password2': [u'This field is required.']} >>> f = UserRegistration({'username': 'adrian', 'password1': 'foo', 'password2': 'bar'}) >>> f.errors() {'__all__': [u'Please make sure your passwords match.']} >>> print f.as_table() - -
Username:
Password1:
Password2:
>>> print f.as_table_with_errors() - -
  • Please make sure your passwords match.
Username:
Password1:
Password2:
>>> print f.as_ul_with_errors() - >>> f = UserRegistration({'username': 'adrian', 'password1': 'foo', 'password2': 'foo'}) >>> f.errors() {} @@ -1205,11 +1175,9 @@ subclass' __init__(). ... self.fields['birthday'] = DateField() >>> p = Person() >>> print p - -
First name:
Last name:
Birthday:
""" if __name__ == "__main__": -- cgit v1.3