From e18bd68dbc64dfe08ae0fbb54591d5c8f7e456eb Mon Sep 17 00:00:00 2001 From: Nick Sandford Date: Sat, 2 Feb 2013 13:21:50 -0800 Subject: [1.5.x] Fixed #19445 -- Skip admin fieldsets validation when the ModelAdmin.get_form() method is overridden. Backport of 0694d2196f0fad --- tests/regressiontests/admin_validation/tests.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests') diff --git a/tests/regressiontests/admin_validation/tests.py b/tests/regressiontests/admin_validation/tests.py index be2500a803..b9b42c6bb9 100644 --- a/tests/regressiontests/admin_validation/tests.py +++ b/tests/regressiontests/admin_validation/tests.py @@ -20,6 +20,18 @@ class InvalidFields(admin.ModelAdmin): form = SongForm fields = ['spam'] +class ValidFormFieldsets(admin.ModelAdmin): + def get_form(self, request, obj=None, **kwargs): + class ExtraFieldForm(SongForm): + name = forms.CharField(max_length=50) + return ExtraFieldForm + + fieldsets = ( + (None, { + 'fields': ('name',), + }), + ) + class ValidationTestCase(TestCase): def test_readonly_and_editable(self): @@ -42,6 +54,14 @@ class ValidationTestCase(TestCase): validate, InvalidFields, Song) + def test_custom_get_form_with_fieldsets(self): + """ + Ensure that the fieldsets validation is skipped when the ModelAdmin.get_form() method + is overridden. + Refs #19445. + """ + validate(ValidFormFieldsets, Song) + def test_exclude_values(self): """ Tests for basic validation of 'exclude' option values (#12689) -- cgit v1.3