Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#24411 closed Bug (fixed)

Creating a model called Item breaks the admin "delete selected" action

Reported by: Michael Angeletti Owned by: Tim Graham
Component: contrib.admin Version: 1.8alpha1
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Michael Angeletti)

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 PEP 469, this might not be the solution. And, (I say jokingly, but for completion sake) what happens when I name my model IterItem?

Change History (6)

comment:1 by Michael Angeletti, 9 years ago

comment:2 by Michael Angeletti, 9 years ago

Description: modified (diff)

comment:3 by Tim Graham, 9 years ago

Component: Template systemcontrib.admin
Owner: changed from nobody to Tim Graham
Status: newassigned
Triage Stage: UnreviewedAccepted
Type: UncategorizedBug
Version: master1.8alpha1

It's a regression in Django 1.8.

comment:4 by Tim Graham, 9 years ago

Has patch: set
Severity: NormalRelease blocker

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

Resolution: fixed
Status: assignedclosed

In 47b35b1844b2adc167e64674824873991e9c4c2b:

Fixed #24411 -- Avoided dict key/method clash in admin delete views.

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

In dfcdf64d475418ed579da2621e331cc4d03a78e5:

[1.8.x] Fixed #24411 -- Avoided dict key/method clash in admin delete views.

Backport of 47b35b1844b2adc167e64674824873991e9c4c2b from master

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