I have a model with data like the following:
Name Value Date
pop1 15 2021-01-19
pup1 2 2021-01-18
pep1 25 2021-01-18
pop2 9 2021-01-17
pap1 1 2021-01-16
pep2 26 2021-01-16
pep3 4 2021-01-16
If i do data = myModel.objects.all()
I obtain all the data in the normal structure, but what I want is obtain it grouped by date. Can this goal be achieved directly?
I ask this because I know how to filter using myModel.objects.filter()
or order the data using myModel.objects.order_by()
. Then, exists something like myModel.objects.regroup('date')
?
EDIT:
The desired output is something like:
date:2021-01-19 >> [[name:pop1, value:15]]
date:2021-01-19 >> [[name:pup1, value:2],[name:pep1, value:25]]
date:2021-01-17 >> [[name:pop2, value:9]]
date:2021-01-16 >> [[name:pap1, value:1],[name:pep2, value:26],[name:pep3, value:4]]
Basically an object with the data regrouped by date.
Thank you very much.