Answers for "count items in a model django rest"

0

count items in a model django rest

CustomerInformation.objects.annotate(lead_count=Count('status',filter=Q(status="lead"))).annotate(client_count=Count('status',filter=Q(status="client")))
Posted by: Guest on July-10-2021
0

count items in a model django rest

class CustomerInformation(models.Model):

    status = (
        ('lead', 'Lead'),
        ('client', 'Client'),
    )

    customer_name = models.CharField(max_length=100)
    status = models.CharField(max_length=100, choices=status, default='lead')
    creator = models.ForeignKey('UserProfile', related_name='customers', on_delete=models.CASCADE, null=True, blank=True)
    created_date = models.DateField(default=timezone.now)
Posted by: Guest on July-10-2021

Python Answers by Framework

Browse Popular Code Answers by Language