mirror of
https://github.com/django/django.git
synced 2025-11-25 05:04:26 +00:00
Fixed #29432 -- Allowed passing an integer to the slice template filter.
This commit is contained in:
parent
39283c8edb
commit
b4fd9b5ad4
2 changed files with 4 additions and 1 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue