mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
[1.5.x] Fixed #19445 -- Skip admin fieldsets validation when the ModelAdmin.get_form() method is overridden.
Backport of 0694d2196f
This commit is contained in:
committed by
Julien Phalip
parent
f28fbe7314
commit
e18bd68dbc
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user