#26267: Template filter "slice" raises TypeError on bound RadioSelect
---------------------------------+--------------------
Reporter: jdufresne | Owner: nobody
Type: Bug | Status: new
Component: Template system | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------
I have a template with the following snippet:
{{{
{% for choice in form.choices|slice:'1:' %}
<li>{{ choice }}</li>
{% endfor %}
}}}
Where choices is a {{{ChoiceField}}} with a {{{RadioSelect}}} widget. This
stopped working in 1.8.
Looking through the code history, this looks like it was introduce in
commit [https://github.com/django/django/commit/5e06fa14 5e06fa14] during
work on ticket #22745.
The change to {{{BoundField.__getitem__()}}}:
{{{
def __getitem__(self, idx):
+ # Prevent unnecessary reevaluation when accessing BoundField's
attrs
+ # from templates.
+ if not isinstance(idx, six.integer_types):
+ raise TypeError
return list(self.__iter__())[idx]
}}}
It no longer accepts a `slice` and will instead raise a {{{TypeError}}}.
--
Ticket URL: <https://code.djangoproject.com/ticket/26267>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.afe48ba8da8ed43d4df2c94903b6fe3b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.