Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#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 Ben Davis, 11 years ago

Cc: Ben Davis added

comment:2 by Tim Graham, 11 years ago

Triage Stage: UnreviewedAccepted

I think the ideal solution would be to get rid of custom logic in AdminReadonlyField as much as possible, adding functionality to django.forms as necessary.

comment:3 by Ben Davis, 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.

https://github.com/django/django/pull/2323

comment:4 by anonymous, 11 years ago

Has there been any update on this?

Thanks,
Dan

comment:5 by Tim Graham <timograham@…>, 11 years ago

Resolution: fixed
Status: newclosed

In 16afffffe87bf8b7de6403329937433ac5096697:

Fixed #22087 -- Made AdminReadonlyField respect ModelForm Meta overrides.

comment:6 by Tim Graham <timograham@…>, 11 years ago

In 24604844866a0b28122a1c47ac85072ea05b9b71:

[1.7.x] Fixed #22087 -- Made AdminReadonlyField respect ModelForm Meta overrides.

Backport of 16afffffe8 from master

comment:7 by Tim Graham, 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.

Note: See TracTickets for help on using tickets.
Back to Top