How to show value of Count Function on my template. Django

I would like to show the total number of employees registered in my database. Using the count function.


def home(request):
    return render(request, 'dashboard.html')

def return_total_employees(request):
    return_total = Employees.objects.aggregate(total=Count('EmployeeCard'))[
    return render(request, 'dashboard.html', {'return_total ': return_total })

My template:

<h1> {{ view.return_total_employees }} </h1>

The dict you're returning in the render function is called context. You can access the value of returned context in your template like this


Back to Top