I have the following model:
class TimeStamp():
mydate = models.DateTime()
value = models.Integer()
cat = models.CharField()
The data table would look something like this:
mydate | value | cat
=======================
1st Jan | 10 | A
2nd Jan | 10 | A
3rd Jan | 10 | A
4th Jan | 5 | A
1st Jan | 5 | B
2nd Jan | 20 | B
3rd Jan | 15 | B
4th Jan | 30 | B
output table would look like, so we join by matching dates, then order by value for A then by value for B. Note the table below is the expected output, notice the order of the dates and ordering of value_A and value_B
mydate | value_A | value_B
==============================
4th Jan | 5 | 30
1st Jan | 10 | 5
3rd Jan | 10 | 15
2nd Jan | 10 | 20
I can obtain 2 querysets:
qs_a = TimeStamp.objects.filter(cat='A')
qs_b = TimeStamp.objects.filter(cat='B')
I'm not sure how to then join these 2 together. Note that the | will merge the 2 sets which is not what I'm after... I would like to join these 2 querysets then order by A then B, so that the list of dates is in order of the values where Cat=A then values where Cat=B.