{{{
{% 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.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/24411#comment:1>
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>
* 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>
* 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>
* 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>
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>