I have this one model where I have fetch published count
, under process count
, rejected count
, received count
on monthly basis
class PreData(models.Model):
status=models.CharField(max_length=200,default=None,null=True)
receivedon=models.DateField(default=None,blank=False,null=True)
publishedon = models.DateField(default=None, blank=True, null=True)
received count
is based on monthly count of receivedon
DateField
in model, published count
is based on monthly count of publishedon
DateField
in model, rejected count
and under process count
is based on count of specific status
value of CharField
in model.
I'm struggling after writing below queries,I'm clueless as to how fetch data to fill the columns(see figure). I'm not sure queries I wrote will help.
The problem comes when I want to zip received_monthly_data
and published_monthly_data
but received_monthly_data
has data from April month and published_monthly_data
didn't have April month. when i zip , results will loose April month. I am not able to figure how to do this.
received_monthly_data = PreData.objects.filter(journaluser=request.user.username).\
annotate(month=TruncMonth('receivedon'),year=TruncYear('receivedon')).values('month','year').\
annotate(c=Count('id')).order_by('-month')
published_monthly_data = PreData.objects.filter(Q(journaluser=request.user.username)&~Q(pdfsenton=None)). \
annotate(month=TruncMonth('publishedon'), year=TruncYear('publishedon')).values('month', 'year'). \
annotate(c=Count('id')).order_by('-month')
underproc_data= PreData.objects.filter(Q(journaluser=request.user.username)&~Q(status="[Published]"))
I need the data to fill these columns
Any help is highly appreciated.