Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to append data in django queryset

def getDatat():
    qs = CustomerInformation.objects.filter(salesDepartment__in=[d]).filter(created_date__range=(start,end))
    qs = qs.annotate(date=TruncMonth('created_date')).values('date').annotate(lead_count=Count('status',filter=Q(status="lead"))).annotate(client_count=Count('status',filter=Q(status="client")))
    qs = qs.values('date', 'client_count', 'lead_count')
    this_v = None
    for next_v in qs:
         if this_v is None:
            this_v = next_v
            yield this_v
            continue
         # Do logic for checking if there's any needed extra values between this_v and next_V
         # yield extra values
         this_v = next_v
         yield this_v
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #append #data #django #queryset
ADD COMMENT
Topic
Name
1+5 =