[Django]-Slicing a list in Django template

50👍

✅

you can just use

{{ mylist|slice:"3:8" }}

28👍

Its simple you will have to pass this in the slice filter then:

{{ mylist|slice:"3:8" }}

This filter takes care of all type of slicing you can perform on a list

e.g. All this would work:

{{ mylist|slice:"3:8" }}

{{ mylist|slice:":2" }}

{{ mylist|slice:"3:" }}

{{ mylist|slice:":" }}

Leave a comment