if django code example
Example 1: count gabarit django
def places(request):
places = Places.objects.order_by('-published_date')[:10]
places_count = Places.objects.count()
return render(
request, 'templates/places.html', {'places':places, 'places_count': places_count}
)
<div class="container">
<h2>Places <span class="badge">{{ places_count }}</span></h2>
</div>
Example 2: if django
{% if athlete_list %}
Number of athletes: {{ athlete_list|length }}
{% elif athlete_in_locker_room_list %}
Athletes should be out of the locker room soon!
{% else %}
No athletes.
{% endif %}