summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-01-28 13:49:51 -0500
committerTim Graham <timograham@gmail.com>2016-01-29 08:08:04 -0500
commit01db3249e5048093c85de33e5395ba737d330d0a (patch)
treee822ced2960ccadfc0e3d29882e6f56ae46b56de /tests
parentefd855481581b5758d866a009bbd1074e74869b4 (diff)
downloaddjango-01db3249e5048093c85de33e5395ba737d330d0a.tar.gz
[1.9.x] Fixed #26129 -- Made invalid forms display initial values of disabled fields.
Backport of 04564eb74d2d92eaf88b22ab8cec7ef45978111e from master
Diffstat (limited to 'tests')
-rw-r--r--tests/forms_tests/tests/test_forms.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py
index 917b5c99d2..00d2045786 100644
--- a/tests/forms_tests/tests/test_forms.py
+++ b/tests/forms_tests/tests/test_forms.py
@@ -718,6 +718,14 @@ class FormsTestCase(SimpleTestCase):
{'birthday': datetime.date(1974, 8, 16), 'name': 'John Doe'}
)
+ # Initial data remains present on invalid forms.
+ data = {}
+ f1 = PersonForm(data, initial={'birthday': datetime.date(1974, 8, 16)})
+ f2 = PersonFormFieldInitial(data)
+ for form in (f1, f2):
+ self.assertFalse(form.is_valid())
+ self.assertEqual(form['birthday'].value(), datetime.date(1974, 8, 16))
+
def test_hidden_data(self):
class SongForm(Form):
name = CharField()