Opened 10 years ago
Last modified 10 years ago
#24411 closed Bug
Creating a model called Item breaks the admin "delete selected" action — at Version 2
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 (last modified by )
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 (2)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
Description: | modified (diff) |
---|