count gabarit django

Solutions on MaxInterview for count gabarit django by the best coders in the world

showing results for - "count gabarit django"
Wallace
01 Jul 2020
1#in template you can use the filter length on your model post
2{{ posts|length }} 
Enrico
28 Apr 2018
1#views.py
2#You should instead pass places_count via the context to the template:
3def places(request):
4    places = Places.objects.order_by('-published_date')[:10]
5    places_count = Places.objects.count()
6    return render(
7        request, 'templates/places.html', {'places':places, 'places_count': places_count}
8    )
9#in your templatee
10<div class="container">
11    <h2>Places <span class="badge">{{ places_count }}</span></h2>
12</div>