1CustomerInformation.objects.annotate(lead_count=Count('status',filter=Q(status="lead"))).annotate(client_count=Count('status',filter=Q(status="client")))
2
1class CustomerInformation(models.Model):
2
3 status = (
4 ('lead', 'Lead'),
5 ('client', 'Client'),
6 )
7
8 customer_name = models.CharField(max_length=100)
9 status = models.CharField(max_length=100, choices=status, default='lead')
10 creator = models.ForeignKey('UserProfile', related_name='customers', on_delete=models.CASCADE, null=True, blank=True)
11 created_date = models.DateField(default=timezone.now)
12