How to select the first item from a list [duplicate]
问题 This question already has answers here : Django Templating: how to access properties of the first item in a list (3 answers) Closed 5 years ago . I have the following for loop that spits out all photos in a list: {% if photos %} {% for photo in photos %} {% thumbnail photo.photo "100x100" crop="center" as im %} <img src="{{ im.url }}" alt="User's photos" data-ajax="{% url 'photo_increase_view' pk=photo.id %}"/> {% endthumbnail %} {% endfor %} {% endif %} How can I just select and display the