﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
19829	Index lookup fails for NumPy arrays in templates	Julien Phalip	nobody	"The following will crash with a `ValueError` when using a NumPy array:

{{{
{{ my_numpy_array.0 }}
}}}

This is because currently Django only handles index lookups for regular Python lists, by catching a `TypeError`. See how differently regular lists and NumPy arrays behave:

{{{#!python
>>> regular_list = [1,2,3,4]
>>> regular_list['0']
Traceback (most recent call last):
  File ""<stdin>"", line 1, in <module>
TypeError: list indices must be integers, not str

>>> import numpy
>>> numpy_array = numpy.array([1,2,3,4])
>>> numpy_array['0']
Traceback (most recent call last):
  File ""<stdin>"", line 1, in <module>
ValueError: field named 0 not found.
}}}

The attached patch fixes this issue by handling `ValueError` too."	Bug	closed	Template system	dev	Normal	fixed			Ready for checkin	1	0	0	0	0	0
