count gabarit django
#in template you can use the filter length on your model post
{{ posts|length }}
count gabarit django
#in template you can use the filter length on your model post
{{ posts|length }}
count gabarit django
#views.py
#You should instead pass places_count via the context to the template:
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}
)
#in your templatee
<div class="container">
<h2>Places <span class="badge">{{ places_count }}</span></h2>
</div>
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us