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
This commit is contained in:
parent
578a31fea3
commit
ee8f6ca405
|
@ -362,7 +362,7 @@ def generic_inlineformset_factory(model, form=ModelForm,
|
||||||
fields=None, exclude=None,
|
fields=None, exclude=None,
|
||||||
extra=3, can_order=False, can_delete=True,
|
extra=3, can_order=False, can_delete=True,
|
||||||
max_num=None,
|
max_num=None,
|
||||||
formfield_callback=lambda f: f.formfield()):
|
formfield_callback=None):
|
||||||
"""
|
"""
|
||||||
Returns an ``GenericInlineFormSet`` for the given kwargs.
|
Returns an ``GenericInlineFormSet`` for the given kwargs.
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from django import forms
|
||||||
from django.contrib.contenttypes.generic import generic_inlineformset_factory
|
from django.contrib.contenttypes.generic import generic_inlineformset_factory
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
@ -221,3 +222,23 @@ class GenericRelationsTests(TestCase):
|
||||||
formset = GenericFormSet(instance=lion, prefix='x')
|
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>
|
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>""")
|
<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))
|
||||||
|
|
Loading…
Reference in New Issue