M
M
ma3xak2018-05-03 12:02:25
Django
ma3xak, 2018-05-03 12:02:25

How to get the first record from the database?

How to get the first record from the database in a template? Now I'm looping through all the entries,

{% for about in aboutText %}
                        <h4 class="h4">{{ about.title }}</h4>
{% endfor %}

And if I need only the first record from the database, how can I get it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Pugachev, 2018-05-03
@ma3xak

{% for about in aboutText|slice:":1" %}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question