diff --git a/django/contrib/contenttypes/generic.py b/django/contrib/contenttypes/generic.py
index 81301cf..2e5a4c5 100644
a
|
b
|
class GenericInlineModelAdmin(InlineModelAdmin):
|
396 | 396 | ct_fk_field = "object_id" |
397 | 397 | formset = BaseGenericInlineFormSet |
398 | 398 | |
399 | | def get_formset(self, request, obj=None): |
| 399 | def get_formset(self, request, obj=None, **kwargs): |
400 | 400 | if self.declared_fieldsets: |
401 | 401 | fields = flatten_fieldsets(self.declared_fieldsets) |
402 | 402 | else: |
… |
… |
class GenericInlineModelAdmin(InlineModelAdmin):
|
420 | 420 | "max_num": self.max_num, |
421 | 421 | "exclude": exclude |
422 | 422 | } |
| 423 | defaults.update(kwargs) |
423 | 424 | return generic_inlineformset_factory(self.model, **defaults) |
424 | 425 | |
425 | 426 | class GenericStackedInline(GenericInlineModelAdmin): |
diff --git a/tests/regressiontests/generic_inline_admin/tests.py b/tests/regressiontests/generic_inline_admin/tests.py
index c40b6dd..d989697 100644
a
|
b
|
|
1 | 1 | # coding: utf-8 |
2 | 2 | |
3 | 3 | from django.conf import settings |
| 4 | from django.contrib.admin.sites import AdminSite |
4 | 5 | from django.contrib.contenttypes.generic import generic_inlineformset_factory |
5 | 6 | from django.test import TestCase |
6 | 7 | |
7 | 8 | # local test models |
8 | 9 | from models import Episode, EpisodeExtra, EpisodeMaxNum, EpisodeExclude, \ |
9 | | Media, EpisodePermanent, MediaPermanentInline, Category |
| 10 | Media, MediaInline, EpisodePermanent, MediaPermanentInline, \ |
| 11 | Category |
10 | 12 | |
11 | 13 | |
12 | 14 | class GenericAdminViewTest(TestCase): |
… |
… |
class NoInlineDeletionTest(TestCase):
|
214 | 216 | fake_request = object() |
215 | 217 | formset = inline.get_formset(fake_request) |
216 | 218 | self.assertFalse(formset.can_delete) |
| 219 | |
| 220 | class GenericInlineModelAdminTest(TestCase): |
| 221 | |
| 222 | def test_get_formset_kwargs(self): |
| 223 | media_inline = MediaInline(Media, AdminSite()) |
| 224 | |
| 225 | # Create a formset with default arguments |
| 226 | formset = media_inline.get_formset(None) |
| 227 | self.assertEqual(formset.max_num, None) |
| 228 | self.assertEqual(formset.can_order, False) |
| 229 | |
| 230 | # Create a formset with custom keyword arguments |
| 231 | formset = media_inline.get_formset(None, max_num=100, can_order=True) |
| 232 | self.assertEqual(formset.max_num, 100) |
| 233 | self.assertEqual(formset.can_order, True) |