R
R
rusyska550112021-03-15 23:59:00
Django
rusyska55011, 2021-03-15 23:59:00

How to render a django list item in a template?

Suppose I have an object a = [45, 66, 77]. I pass it from views to the html page. How can I display the first element, and only?
Tried

<p> {{ a[0] }} </p>
<p> {{ a | [0] }} </p>
<p> {{ a | a[0] }} </p>
<p> {{ a.get(0) }} </p>
<p> {{ a | get(0) }} </p>

Etc... I
didn't find it in the documentation

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2021-03-16
@rusyska55011

Didn't find it in the documentation
https://docs.djangoproject.com/en/3.1/ref/template...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question