summaryrefslogtreecommitdiff
path: root/tests/regressiontests/forms/tests.py
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2007-01-11 00:04:27 +0000
committerAdrian Holovaty <adrian@holovaty.com>2007-01-11 00:04:27 +0000
commit73d62743e9cc27f09a5e30bcf7b0dbe64d6108de (patch)
tree672686be7ab66b213033bcf3c6c1969076be7800 /tests/regressiontests/forms/tests.py
parent963ccd7cb4c923a70dfcf4b321fa74a099c69948 (diff)
newforms: Added unit tests and docs explaining that clean_data will only ever contain fields of the form, even if extra fields are passed in data
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4306 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/forms/tests.py')
-rw-r--r--tests/regressiontests/forms/tests.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/regressiontests/forms/tests.py b/tests/regressiontests/forms/tests.py
index d185f1ceb8..1fc6b3253f 100644
--- a/tests/regressiontests/forms/tests.py
+++ b/tests/regressiontests/forms/tests.py
@@ -1647,6 +1647,17 @@ u'* This field is required.'
>>> print p['birthday']
<input type="text" name="birthday" id="id_birthday" />
+clean_data will always *only* contain a key for fields defined in the
+Form, even if you pass extra data when you define the Form. In this
+example, we pass a bunch of extra fields to the form constructor,
+but clean_data contains only the form's fields.
+>>> data = {'first_name': u'John', 'last_name': u'Lennon', 'birthday': u'1940-10-9', 'extra1': 'hello', 'extra2': 'hello'}
+>>> p = Person(data)
+>>> p.is_valid()
+True
+>>> p.clean_data
+{'first_name': u'John', 'last_name': u'Lennon', 'birthday': datetime.date(1940, 10, 9)}
+
"auto_id" tells the Form to add an "id" attribute to each form element.
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. It will also put a <label> around