Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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")))
Comment

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)
Comment

PREVIOUS NEXT
Code Example
Python :: reverse row order padnas 
Python :: File C:Users7shalPycharmProjectsItsa Me Malariomain.py, line 2 from pygame.locals import import ^ SyntaxError: invalid syntax 
Python :: max path limit python 
Python :: entry point not found python.exe 
Python :: python check if not none or empty 
Python :: new sytax in python 3 
Python :: eager tensor to numpy 
Python :: python http handler iis 
Python :: identifying strings python 
Python :: numpy prod 
Python :: how to access item in list private in python 
Python :: jupyter early exit cell 
Python :: python find first char index from a string stackoverflow 
Python :: sum of the first nth term of series codewars python 
Python :: standardscalar 
Python :: not all arguments converted during string formatting postgresql 
Python :: accessing list python 
Python :: python read text on screen 
Python :: How to Use Sets to Remove Duplicate Items in Other Data Structures 
Python :: double linked list python 
Python :: how to get each word in a string 
Python :: Copy an Object in Python using = operator 
Python :: python Fibonacci series up to n 
Python :: gensim loop through models 
Python :: while except python 
Python :: python keyerror 0 
Python :: needle in haystack 
Python :: increase tkinter window resolution 
Python :: if else ifadesi 
Python :: django command to fetch all columns of a table 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =