diff --git a/django/contrib/contenttypes/generic.py b/django/contrib/contenttypes/generic.py
index 76f8eaf..7efb603 100644
a
|
b
|
def generic_inlineformset_factory(model, form=ModelForm,
|
365 | 365 | fields=None, exclude=None, |
366 | 366 | extra=3, can_order=False, can_delete=True, |
367 | 367 | max_num=None, |
368 | | formfield_callback=lambda f: f.formfield()): |
| 368 | formfield_callback=None): |
369 | 369 | """ |
370 | 370 | Returns an ``GenericInlineFormSet`` for the given kwargs. |
371 | 371 | |
… |
… |
class GenericInlineModelAdmin(InlineModelAdmin):
|
399 | 399 | ct_fk_field = "object_id" |
400 | 400 | formset = BaseGenericInlineFormSet |
401 | 401 | |
402 | | def get_formset(self, request, obj=None): |
| 402 | def get_formset(self, request, obj=None, **kwargs): |
403 | 403 | if self.declared_fieldsets: |
404 | 404 | fields = flatten_fieldsets(self.declared_fieldsets) |
405 | 405 | else: |
… |
… |
class GenericInlineModelAdmin(InlineModelAdmin):
|
423 | 423 | "max_num": self.max_num, |
424 | 424 | "exclude": exclude |
425 | 425 | } |
| 426 | defaults.update(kwargs) |
426 | 427 | return generic_inlineformset_factory(self.model, **defaults) |
427 | 428 | |
428 | 429 | class GenericStackedInline(GenericInlineModelAdmin): |
diff --git a/tests/modeltests/generic_relations/tests.py b/tests/modeltests/generic_relations/tests.py
index 3d25301..fcf7d70 100644
a
|
b
|
|
| 1 | from django import forms |
1 | 2 | from django.contrib.contenttypes.generic import generic_inlineformset_factory |
2 | 3 | from django.contrib.contenttypes.models import ContentType |
3 | 4 | from django.test import TestCase |
… |
… |
class GenericRelationsTests(TestCase):
|
221 | 222 | formset = GenericFormSet(instance=lion, prefix='x') |
222 | 223 | 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> |
223 | 224 | <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>""") |
| 225 | |
| 226 | |
| 227 | class CustomWidget(forms.CharField): |
| 228 | pass |
| 229 | |
| 230 | |
| 231 | class TaggedItemForm(forms.ModelForm): |
| 232 | class Meta: |
| 233 | model = TaggedItem |
| 234 | widgets = {'tag': CustomWidget} |
| 235 | |
| 236 | |
| 237 | class GenericInlineFormsetTest(TestCase): |
| 238 | """ |
| 239 | Regression for #14572: Using base forms with widgets |
| 240 | defined in Meta should not raise errors. |
| 241 | """ |
| 242 | |
| 243 | def test_generic_inlineformset_factory(self): |
| 244 | Formset = generic_inlineformset_factory(TaggedItem, TaggedItemForm) |
| 245 | form = Formset().forms[0] |
| 246 | self.assertTrue(isinstance(form['tag'].field.widget, CustomWidget)) |