mirror of https://github.com/django/django.git
Fixed #29432 -- Allowed passing an integer to the slice template filter.
This commit is contained in:
parent
39283c8edb
commit
b4fd9b5ad4
|
@ -573,7 +573,7 @@ def slice_filter(value, arg):
|
|||
"""
|
||||
try:
|
||||
bits = []
|
||||
for x in arg.split(':'):
|
||||
for x in str(arg).split(':'):
|
||||
if not x:
|
||||
bits.append(None)
|
||||
else:
|
||||
|
|
|
@ -26,6 +26,9 @@ class FunctionTests(SimpleTestCase):
|
|||
def test_index(self):
|
||||
self.assertEqual(slice_filter('abcdefg', '1'), 'a')
|
||||
|
||||
def test_index_integer(self):
|
||||
self.assertEqual(slice_filter('abcdefg', 1), 'a')
|
||||
|
||||
def test_negative_index(self):
|
||||
self.assertEqual(slice_filter('abcdefg', '-1'), 'abcdef')
|
||||
|
||||
|
|
Loading…
Reference in New Issue