summaryrefslogtreecommitdiff
path: root/tests/regressiontests/model_forms_regress/tests.py
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2011-08-23 04:08:24 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2011-08-23 04:08:24 +0000
commita5cbb892f8206c8f4ae8fd1bcff93b8251e6264e (patch)
treefbfd1c7725d96882225e2ee29e60300852b80299 /tests/regressiontests/model_forms_regress/tests.py
parent1f770c62da69866835bb8fc9355128b6b493a97e (diff)
Fixed #15315 -- Added support for the 'widget' argument to modelform_factory. Thanks to SardarNL and Will Hardy for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16659 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/model_forms_regress/tests.py')
-rw-r--r--tests/regressiontests/model_forms_regress/tests.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/regressiontests/model_forms_regress/tests.py b/tests/regressiontests/model_forms_regress/tests.py
index 9860c2e1ad..05b8abd4d3 100644
--- a/tests/regressiontests/model_forms_regress/tests.py
+++ b/tests/regressiontests/model_forms_regress/tests.py
@@ -275,6 +275,20 @@ class FormFieldCallbackTests(TestCase):
Form = modelform_factory(Person, form=BaseForm)
self.assertTrue(Form.base_fields['name'].widget is widget)
+ def test_factory_with_widget_argument(self):
+ """ Regression for #15315: modelform_factory should accept widgets
+ argument
+ """
+ widget = forms.Textarea()
+
+ # Without a widget should not set the widget to textarea
+ Form = modelform_factory(Person)
+ self.assertNotEqual(Form.base_fields['name'].widget.__class__, forms.Textarea)
+
+ # With a widget should not set the widget to textarea
+ Form = modelform_factory(Person, widgets={'name':widget})
+ self.assertEqual(Form.base_fields['name'].widget.__class__, forms.Textarea)
+
def test_custom_callback(self):
"""Test that a custom formfield_callback is used if provided"""