Fieldsets' validation doesn't call get_form
|Reported by:||Krzysztof Jurewicz||Owned by:||Nick Sandford|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
In django.contrib.admin.validation, function check_formfield checks presence of a field based on "form" attribute on admin class. If get_form method is overriden and it returns form class which adds some additional fields, those cannot be used in "fieldsets" attribute because ImproperlyConfigured exception is raised.
The workaround is to use undocumented get_fieldsets method to specify additional fields instead of "fieldsets" attribute.
The easiest way to fix this would be probably to disable fieldsets' validation entirely (as we are not able to anticipate what will be the result of calling get_form) or to make get_fieldsets method a documented one and make a note that if we add fields in get_form, then we should not set "fieldsets" attribute.
Change History (10)
comment:3 Changed 4 years ago by
|Owner:||changed from nobody to Nick Sandford|
|Status:||new → assigned|