diff --git a/tests/regressiontests/forms/tests.py b/tests/regressiontests/forms/tests.py index 21bd378f1f..e63ca097f7 100644 --- a/tests/regressiontests/forms/tests.py +++ b/tests/regressiontests/forms/tests.py @@ -1194,8 +1194,22 @@ Form.clean() still needs to return a dictionary of all clean data: >>> f.clean() {'username': u'adrian', 'password1': u'foo', 'password2': u'foo'} - - +It's possible to construct a Form dynamically by adding to the self.fields +dictionary in __init__(). Don't forget to call Form.__init__() within the +subclass' __init__(). +>>> class Person(Form): +... first_name = CharField() +... last_name = CharField() +... def __init__(self): +... super(Person, self).__init__() +... self.fields['birthday'] = DateField() +>>> p = Person() +>>> print p + + + + +
First name:
Last name:
Birthday:
""" if __name__ == "__main__":