#26267 closed Bug (fixed)
Template filter "slice" raises TypeError on bound RadioSelect
Reported by: | Jon Dufresne | Owned by: | nobody |
---|---|---|---|
Component: | Template system | Version: | 1.8 |
Severity: | Release blocker | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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 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
.
Change History (7)
comment:1 by , 9 years ago
Severity: | Normal → Release blocker |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 9 years ago
Has patch: | set |
---|
comment:4 by , 9 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Note:
See TracTickets
for help on using tickets.
https://github.com/django/django/pull/6184