我有以下列表:
{% for artist_form in artist_formset %}
...
{% endfor %}
如何只显示列表中的最后一个结果?
由于
答案 0 :(得分:3)
来自文档:https://docs.djangoproject.com/en/1.6/ref/templates/builtins/#last
使用' last'标记以获取列表的最后一项。
答案 1 :(得分:2)
在views.py中:
last_artist = artist_formset[-1]
在your-template.html中:
{{ last_artist }}