B
B
bitbuff2017-10-22 17:38:35
Django
bitbuff, 2017-10-22 17:38:35

How to slice an array in a django template?

There is an array arr passed to the template. How to slice arr[:5] in template ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WizardW, 2017-10-22
@WizardW

Here, try this https://djbook.ru/rel1.9/ref/templates/builtins.ht...

{{ some_list|slice:":2" }}
Если some_list равно ['a', 'b', 'c'], вернет ['a', 'b'].

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question