class Orders(models.Model):
orderid = models.IntegerField(db_column='orderID', primary_key=True)
pickupdate = models.DateField(db_column='pickupDate', blank=True, null=True)
I want to display total records in the Model for each month. The solution that I have found require me to enter year
Orders.objects.filter(pickupdate__year = '2006').values_list('pickupdate__month').annotate(total = Count('orderid')
The results from the queryset above are like this :
<QuerySet [(1, 31), (2, 27), (3, 31), (4, 30), (5, 31), (6, 29), (7, 30), (8, 31), (9, 30), (10, 31), (11, 30),
(12, 31)]>
I want that the queryset able to get the monthly range automatically from the database,without the need to put year to the queryset
The data that I want to display is like this :
Month | Total
January 2007 | 1
February 2007| 2
etc
enter code here