#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 )
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 , 11 years ago
comment:2 by , 11 years ago
| Description: | modified (diff) |
|---|
comment:3 by , 11 years ago
| Component: | Template system → contrib.admin |
|---|---|
| Owner: | changed from to |
| Status: | new → assigned |
| Triage Stage: | Unreviewed → Accepted |
| Type: | Uncategorized → Bug |
| Version: | master → 1.8alpha1 |
comment:5 by , 11 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
It's a regression in Django 1.8.