Opened 10 years ago

Last modified 10 years ago

#24411 closed Bug

Creating a model called Item breaks the admin "delete selected" action — at Initial Version

Reported by: Michael Angeletti Owned by: nobody
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

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 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 (0)

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