[Django] #24411: Creating a model called Item breaks the admin "delete selected" action

6 views
Skip to first unread message

Django

unread,
Feb 25, 2015, 12:34:26 AM2/25/15
to django-...@googlegroups.com
#24411: Creating a model called Item breaks the admin "delete selected" action
---------------------------------+--------------------
Reporter: yoyoma | Owner: nobody
Type: Uncategorized | Status: new
Component: Template system | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------
{{{contrib/admin/templates/admin/includes/object_delete_summary.html}}}
contains the following:

{{{
{% for model_name, object_count in model_count.items %}
}}}

Given a model named {{{Item}}}, this breaks the admin's "delete selected
<model name>" action. The reason for this is that {{{model_count}}} looks
something like this:

{{{
{'items': 1}
}}}

Because Django templates resolves {{{model_count.items}}} to
{{{model_count['items']}}} (which, in the above example is {{{1}}}), this
results in the template system trying to iterate an integer.

Now, using changing that line in the template to:

{{{
{% for model_name, object_count in model_count.iteritems %}
}}}

fixes the issue, but due to [http://legacy.python.org/dev/peps/pep-0469/
PEP 469], this might not be the solution, and (I say jokingly, but for
completion sake), what happens when I name my model {{{IterItem}}}?

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

Django

unread,
Feb 25, 2015, 12:35:59 AM2/25/15
to django-...@googlegroups.com
#24411: Creating a model called Item breaks the admin "delete selected" action
---------------------------------+--------------------------------------

Reporter: yoyoma | Owner: nobody
Type: Uncategorized | Status: new
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


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

Django

unread,
Feb 25, 2015, 12:37:23 AM2/25/15
to django-...@googlegroups.com
#24411: Creating a model called Item breaks the admin "delete selected" action
---------------------------------+--------------------------------------

Reporter: yoyoma | Owner: nobody
Type: Uncategorized | Status: new
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

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

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Description changed by yoyoma:

Old description:

> {{{contrib/admin/templates/admin/includes/object_delete_summary.html}}}
> contains the following:
>
> {{{
> {% for model_name, object_count in model_count.items %}
> }}}
>
> Given a model named {{{Item}}}, this breaks the admin's "delete selected
> <model name>" action. The reason for this is that {{{model_count}}} looks
> something like this:
>
> {{{
> {'items': 1}
> }}}
>
> Because Django templates resolves {{{model_count.items}}} to
> {{{model_count['items']}}} (which, in the above example is {{{1}}}), this
> results in the template system trying to iterate an integer.
>
> Now, using changing that line in the template to:
>
> {{{
> {% for model_name, object_count in model_count.iteritems %}
> }}}
>
> fixes the issue, but due to [http://legacy.python.org/dev/peps/pep-0469/
> PEP 469], this might not be the solution, and (I say jokingly, but for
> completion sake), what happens when I name my model {{{IterItem}}}?

New description:

{{{contrib/admin/templates/admin/includes/object_delete_summary.html}}}
contains the following:

{{{
{% for model_name, object_count in model_count.items %}
}}}

Given a model named {{{Item}}}, this breaks the admin's "delete selected
<model name>" action. The reason for this is that {{{model_count}}} looks
something like this:

{{{
{'items': 1}
}}}

Because Django templates resolves {{{model_count.items}}} to
{{{model_count['items']}}} (which, in the above example is {{{1}}}), this
results in the template system trying to iterate an integer.

Now, changing the offending line in the template to:

{{{
{% for model_name, object_count in model_count.iteritems %}
}}}

incidentally addresses the issue, but due to


[http://legacy.python.org/dev/peps/pep-0469/ PEP 469], this might not be

the solution. And, (I say jokingly, but for completion sake) what happens


when I name my model {{{IterItem}}}?

--

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

Django

unread,
Feb 25, 2015, 7:04:07 AM2/25/15
to django-...@googlegroups.com
#24411: Creating a model called Item breaks the admin "delete selected" action
-------------------------------+-------------------------------------
Reporter: yoyoma | Owner: timgraham
Type: Bug | Status: assigned
Component: contrib.admin | Version: 1.8alpha1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

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

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

* status: new => assigned
* component: Template system => contrib.admin
* version: master => 1.8alpha1
* owner: nobody => timgraham
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted


Comment:

It's a regression in Django 1.8.

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

Django

unread,
Feb 25, 2015, 7:17:58 AM2/25/15
to django-...@googlegroups.com
#24411: Creating a model called Item breaks the admin "delete selected" action
---------------------------------+-------------------------------------

Reporter: yoyoma | Owner: timgraham
Type: Bug | Status: assigned
Component: contrib.admin | Version: 1.8alpha1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* has_patch: 0 => 1
* severity: Normal => Release blocker


Comment:

[https://github.com/django/django/pull/4208 PR]

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

Django

unread,
Feb 25, 2015, 8:07:29 AM2/25/15
to django-...@googlegroups.com
#24411: Creating a model called Item breaks the admin "delete selected" action
---------------------------------+-------------------------------------
Reporter: yoyoma | Owner: timgraham
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.8alpha1
Severity: Release blocker | Resolution: fixed

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

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

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


Comment:

In [changeset:"47b35b1844b2adc167e64674824873991e9c4c2b"]:
{{{
#!CommitTicketReference repository=""
revision="47b35b1844b2adc167e64674824873991e9c4c2b"
Fixed #24411 -- Avoided dict key/method clash in admin delete views.
}}}

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

Django

unread,
Feb 25, 2015, 8:07:42 AM2/25/15
to django-...@googlegroups.com
#24411: Creating a model called Item breaks the admin "delete selected" action
---------------------------------+-------------------------------------
Reporter: yoyoma | Owner: timgraham
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.8alpha1
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

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

In [changeset:"dfcdf64d475418ed579da2621e331cc4d03a78e5"]:
{{{
#!CommitTicketReference repository=""
revision="dfcdf64d475418ed579da2621e331cc4d03a78e5"
[1.8.x] Fixed #24411 -- Avoided dict key/method clash in admin delete
views.

Backport of 47b35b1844b2adc167e64674824873991e9c4c2b from master
}}}

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

Reply all
Reply to author
Forward
0 new messages