Re: [Django] #11715: If change mutable list "inlines" in one admin options then it will change "inlines" for all admin options.

11 views
Skip to first unread message

Django

unread,
Feb 15, 2012, 10:41:56 AM2/15/12
to django-...@googlegroups.com
#11715: If change mutable list "inlines" in one admin options then it will change
"inlines" for all admin options.
-------------------------------------+-------------------------------------
Reporter: aiv | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.1
Severity: Normal | Resolution:
Keywords: inlines admin | Triage Stage: Accepted
options | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 1 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by mjtamlyn):

* cc: mjtamlyn (added)
* ui_ux: => 0
* easy: => 0


Comment:

I agree with this being an issue - and a weird one to debug too!

I'd extend it to actions as well which would suffer from the same issue.
Whilst it would potentially break some code to change it to a tuple, I
would say this is more correct, an also consistent with the other
attributes such as `list_filter`.

What exactly is the issue with the current implementation?

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

Django

unread,
Jan 1, 2022, 12:18:11 PM1/1/22
to django-...@googlegroups.com
#11715: If change mutable list "inlines" in one admin options then it will change
"inlines" for all admin options.
-------------------------------------+-------------------------------------
Reporter: Alexander Ivanov | Owner: Jacob
Type: | Walls
Cleanup/optimization | Status: assigned

Component: contrib.admin | Version: 1.1
Severity: Normal | Resolution:
Keywords: inlines admin | Triage Stage: Accepted
options |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* owner: nobody => Jacob Walls
* needs_better_patch: 1 => 0
* status: new => assigned
* type: Bug => Cleanup/optimization


Comment:

This issue predates the system check framework. Trying the original
example (I created a new class in the `admin_inlines` test suite) now
catches errors before failing at the db layer:
{{{
<class 'admin_inlines.admin.FootNoteAuditInline'>: (admin.E202)
'admin_inlines.FootNoteAudit' has no ForeignKey to
'admin_inlines.ShowInlineParent'.
}}}

> What exactly is the issue with the current implementation?

I think if there is one, it's that folks might believe they can mutate the
`inlines` on ''instances'' of `ModelAdmin`, but that's user error if
they're not willing to accept it applying to all model admins.

[https://github.com/django/django/pull/15270 PR] clarifies the intended
immutability of the `inlines` attribute of `ModelAdmin` by defaulting to
`()`, but we could also just close as user error.

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

Django

unread,
Jan 1, 2022, 12:25:11 PM1/1/22
to django-...@googlegroups.com
#11715: If change mutable list "inlines" in one admin options then it will change
"inlines" for all admin options.
-------------------------------------+-------------------------------------
Reporter: Alexander Ivanov | Owner: Jacob
Type: | Walls
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: 1.1
Severity: Normal | Resolution:
Keywords: inlines admin | Triage Stage: Accepted
options |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* needs_tests: 1 => 0


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

Django

unread,
Jan 11, 2022, 4:10:16 AM1/11/22
to django-...@googlegroups.com
#11715: If change mutable list "inlines" in one admin options then it will change
"inlines" for all admin options.
-------------------------------------+-------------------------------------
Reporter: Alexander Ivanov | Owner: Jacob
Type: | Walls
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: 1.1
Severity: Normal | Resolution:
Keywords: inlines admin | Triage Stage: Ready for
options | checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* stage: Accepted => Ready for checkin


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

Django

unread,
Jan 11, 2022, 6:24:17 AM1/11/22
to django-...@googlegroups.com
#11715: If change mutable list "inlines" in one admin options then it will change
"inlines" for all admin options.
-------------------------------------+-------------------------------------
Reporter: Alexander Ivanov | Owner: Jacob
Type: | Walls
Cleanup/optimization | Status: closed
Component: contrib.admin | Version: 1.1
Severity: Normal | Resolution: fixed

Keywords: inlines admin | Triage Stage: Ready for
options | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

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


Comment:

In [changeset:"dc9deea8e85641695e489e43ed5d5638134c15c7" dc9deea8]:
{{{
#!CommitTicketReference repository=""
revision="dc9deea8e85641695e489e43ed5d5638134c15c7"
Fixed #11715 -- Changed default value of ModelAdmin.actions/inlines to
empty tuples.

This clarifies the intended pattern of overwriting the default value
rather than mutating it.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/11715#comment:8>

Reply all
Reply to author
Forward
0 new messages