我有两个应用程序,每个应用程序都有一个模型:
公司 app models.py
class Company(models.Model):
name = models.CharField()
address = models.CharField()
客户端 app models.py
class Client(models.Model):
company = models.ForeignKey(Company)
name = models.CharField()
我有我公司的列表视图:
class CompanyListView(ListView):
model = Company
form_class = CompanyForm
def get_context_data(self, **kwargs):
context = super(CompanyListView, self).get_context_data(**kwargs)
context[client_list] = ???
return context
我的问题是如何传递到与特定公司相关的context[client_list]
客户列表计数?