Fieldsets' validation doesn't call get_form
|Reported by:||KJ||Owned by:||slurms|
|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:1 Changed 4 years ago by russellm
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted
comment:3 Changed 3 years ago by slurms
- Has patch set
- Owner changed from nobody to slurms
- Status changed from new to assigned
comment:4 Changed 3 years ago by Julien Phalip <jphalip@…>
- Resolution set to fixed
- Status changed from assigned to closed
comment:7 Changed 3 years ago by lukeplant
- Resolution fixed deleted
- Status changed from closed to new