[Django] #22087: ModelForm Meta overrides are ignored by AdminReadonlyField

11 views
Skip to first unread message

Django

unread,
Feb 18, 2014, 4:58:44 PM2/18/14
to django-...@googlegroups.com
#22087: ModelForm Meta overrides are ignored by AdminReadonlyField
-------------------------------+--------------------
Reporter: bendavis78 | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------
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:
[https://docs.djangoproject.com/en/dev/topics/forms/modelforms
/#overriding-the-default-fields 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.

--
Ticket URL: <https://code.djangoproject.com/ticket/22087>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 18, 2014, 4:58:54 PM2/18/14
to django-...@googlegroups.com
#22087: ModelForm Meta overrides are ignored by AdminReadonlyField
-------------------------------+--------------------------------------

Reporter: bendavis78 | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by bendavis78):

* cc: bendavis78 (added)
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/22087#comment:1>

Django

unread,
Feb 18, 2014, 5:40:00 PM2/18/14
to django-...@googlegroups.com
#22087: ModelForm Meta overrides are ignored by AdminReadonlyField
-------------------------------+------------------------------------

Reporter: bendavis78 | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by timo):

* stage: Unreviewed => Accepted


Comment:

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/22087#comment:2>

Django

unread,
Feb 18, 2014, 5:55:39 PM2/18/14
to django-...@googlegroups.com
#22087: ModelForm Meta overrides are ignored by AdminReadonlyField
-------------------------------+------------------------------------

Reporter: bendavis78 | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by bendavis78):

* has_patch: 0 => 1


Comment:

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

--
Ticket URL: <https://code.djangoproject.com/ticket/22087#comment:3>

Django

unread,
Mar 6, 2014, 11:52:30 AM3/6/14
to django-...@googlegroups.com
#22087: ModelForm Meta overrides are ignored by AdminReadonlyField
-------------------------------+------------------------------------

Reporter: bendavis78 | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by anonymous):

Has there been any update on this?

Thanks,
Dan

--
Ticket URL: <https://code.djangoproject.com/ticket/22087#comment:4>

Django

unread,
Mar 25, 2014, 9:34:13 AM3/25/14
to django-...@googlegroups.com
#22087: ModelForm Meta overrides are ignored by AdminReadonlyField
-------------------------------+------------------------------------
Reporter: bendavis78 | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"16afffffe87bf8b7de6403329937433ac5096697"]:
{{{
#!CommitTicketReference repository=""
revision="16afffffe87bf8b7de6403329937433ac5096697"
Fixed #22087 -- Made AdminReadonlyField respect ModelForm Meta overrides.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22087#comment:5>

Django

unread,
Mar 25, 2014, 9:35:23 AM3/25/14
to django-...@googlegroups.com
#22087: ModelForm Meta overrides are ignored by AdminReadonlyField
-------------------------------+------------------------------------
Reporter: bendavis78 | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: master

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"24604844866a0b28122a1c47ac85072ea05b9b71"]:
{{{
#!CommitTicketReference repository=""
revision="24604844866a0b28122a1c47ac85072ea05b9b71"
[1.7.x] Fixed #22087 -- Made AdminReadonlyField respect ModelForm Meta
overrides.

Backport of 16afffffe8 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22087#comment:6>

Django

unread,
Mar 25, 2014, 9:38:56 AM3/25/14
to django-...@googlegroups.com
#22087: ModelForm Meta overrides are ignored by AdminReadonlyField
-------------------------------+------------------------------------
Reporter: bendavis78 | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: master

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by timo):

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/22087#comment:7>

Reply all
Reply to author
Forward
0 new messages