In Django, how does one give an attribute field name an alias that can be used to manipulate a queryset?
Background: I have a queryset where the underlying model has an auto-generating time field called "submitted_on". I want to use an alias for this time field (i.e. "date"). Why? Because I will concatenate this queryset with another one (with the same underlying model), and then order_by('-date')
. Needless to say, this latter qset already has a 'date' attribute (attached via annotate()).
How do I make a 'date' alias for the former queryset? Currently, I'm doing something I feel is an inefficient hack: qset1 = qset1.annotate(date=Max('submitted_on'))
I'm using Django 1.5 and Python 2.7.