diff options
| author | Honza Král <honza.kral@gmail.com> | 2011-05-17 12:45:02 +0000 |
|---|---|---|
| committer | Honza Král <honza.kral@gmail.com> | 2011-05-17 12:45:02 +0000 |
| commit | ee8f6ca4054dc74f2846a3639dcdb7dc8c8b18b3 (patch) | |
| tree | 84d9d9ca3e3f153e8de5e120aea63c3c3ef8304b /tests | |
| parent | 578a31fea3cb439f6bfeeb7825ac835820a9f58c (diff) | |
Fixed #14572 -- generic_inlineformset_factory shouldn't specify default formfield_callback. Thanks prestontimmons!
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16234 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/modeltests/generic_relations/tests.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/modeltests/generic_relations/tests.py b/tests/modeltests/generic_relations/tests.py index 3d253010ff..a2bf3bedf6 100644 --- a/tests/modeltests/generic_relations/tests.py +++ b/tests/modeltests/generic_relations/tests.py @@ -1,3 +1,4 @@ +from django import forms from django.contrib.contenttypes.generic import generic_inlineformset_factory from django.contrib.contenttypes.models import ContentType from django.test import TestCase @@ -221,3 +222,23 @@ class GenericRelationsTests(TestCase): formset = GenericFormSet(instance=lion, prefix='x') self.assertEqual(u''.join(form.as_p() for form in formset.forms), u"""<p><label for="id_x-0-tag">Tag:</label> <input id="id_x-0-tag" type="text" name="x-0-tag" maxlength="50" /></p> <p><label for="id_x-0-DELETE">Delete:</label> <input type="checkbox" name="x-0-DELETE" id="id_x-0-DELETE" /><input type="hidden" name="x-0-id" id="id_x-0-id" /></p>""") + + +class CustomWidget(forms.CharField): + pass + +class TaggedItemForm(forms.ModelForm): + class Meta: + model = TaggedItem + widgets = {'tag': CustomWidget} + +class GenericInlineFormsetTest(TestCase): + """ + Regression for #14572: Using base forms with widgets + defined in Meta should not raise errors. + """ + + def test_generic_inlineformset_factory(self): + Formset = generic_inlineformset_factory(TaggedItem, TaggedItemForm) + form = Formset().forms[0] + self.assertTrue(isinstance(form['tag'].field.widget, CustomWidget)) |
