1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #18681 -- GenericInlineModelAdmin.get_formset() no longer bypasses get_fieldsets().

Refs 23e1b59 which already fixed this issue for ModelAdmin and InlineModelAdmin.
This commit is contained in:
Loic Bistuer
2013-07-31 12:50:39 +07:00
committed by Tim Graham
parent 920b242e30
commit a0ed2f9260
2 changed files with 23 additions and 3 deletions

View File

@@ -325,3 +325,23 @@ class GenericInlineModelAdminTest(TestCase):
self.assertEqual(
list(list(ma.get_formsets(request))[0]().forms[0].fields),
['description', 'keywords', 'id', 'DELETE'])
def test_get_fieldsets(self):
# Test that get_fieldsets is called when figuring out form fields.
# Refs #18681.
class MediaForm(ModelForm):
class Meta:
model = Media
fields = '__all__'
class MediaInline(GenericTabularInline):
form = MediaForm
model = Media
can_delete = False
def get_fieldsets(self, request, obj=None):
return [(None, {'fields': ['url', 'description']})]
ma = MediaInline(Media, self.site)
form = ma.get_formset(None).form
self.assertEqual(form._meta.fields, ['url', 'description'])