#22087 closed Bug (fixed)
ModelForm Meta overrides are ignored by AdminReadonlyField
Reported by: | Ben Davis | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Ben Davis | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
In some cases, we may want to override the label and/or help text for admin fields. This can be done on the ModelForm
's Meta class, or by passing the overrides to ModelAdmin.get_form
. See documentation: Overriding the default fields
When a field is readonly, the AdminReadonlyField
class ignores the form overrides. Ideally the AdminReadonlyField
should check first for the overrides on form._meta
, and fallback to the label_for_field()
and help_text_for_field()
functions.
Change History (7)
comment:1 by , 11 years ago
Cc: | added |
---|
comment:2 by , 11 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 11 years ago
Has patch: | set |
---|
Hmm, I'm not sure how you could avoid custom logic in the AdminReadonlyField for this. This bug is only relevant to the admin, which already creates wrappers around every field. The bug is in the wrapper itself, not with the forms.
At any rate, I've created a pull request for a fix, with tests. Let me know what you think.
comment:5 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:7 by , 11 years ago
We could backport the fix to 1.6.x as it's a bug in a new feature, but I haven't done so because there were several conflicts. Feel free to send a PR for that along with a note in the 1.6.3 release notes if you'd like.
I think the ideal solution would be to get rid of custom logic in
AdminReadonlyField
as much as possible, adding functionality todjango.forms
as necessary.