开发者

Help with django filters

I am have a list of "Entries"

I want to get the first entry in the list's "title".

In the template I tried writing

{{ Entries|first.title }} 

But it results in an erro开发者_StackOverflow中文版r.

Is there a way to achieve this without writing a loop or doing it in the view?


Assuming you passed a list of Entries to the template under the name 'Entries',

{{ Entries.0.title }}

will give you the title of the first entry in the list. The first filter isn't the shortest path to where you want to go in this case.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜