我正在尝试计算所有数据,并将其显示为模板上的数字。
这是我的
models.py
class Employee(models.Model):
uid = models.CharField(max_length=100)
name = models.CharField(max_length=100)
def __str__(self):
return self.name
这是我的
views.py
class EmployeeListView(ListView):
context_object_name = 'employees'
model = models.Employee
我的
employee.html
<h5 class='margin-bottom'>Total Data {{ employee_set.count }}</h5>
正在尝试使用
_set.count
但这不管用。