Answers for "count gabarit django"

1

count gabarit django

#in template you can use the filter length on your model post
{{ posts|length }}
Posted by: Guest on December-22-2020
1

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>
Posted by: Guest on December-22-2020

Python Answers by Framework

Browse Popular Code Answers by Language