Thanks for the answer! Do you think it would be practical to let the orm generate the base query and then doing a replace on the column name? I was thinking of this approach as a custom manager method to return a raw result.
This would allow me the generate a case statement for the column and I could dynamically create it. Ant On 14/05/2014 7:25 AM, "Tom Evans" <[email protected]> wrote: > On Tue, May 13, 2014 at 11:04 PM, Anthony <[email protected]> wrote: > > Basically when a queryset like > > instance.annotate(totals=Count('item_description')[:3] like > > PC 10 > > Mac 7 > > Mouse 5 > > Keyboard 4 > > > > I want to combine PC and Mac as say: Desktop so the results become > > > > Desktop 17 > > Mac 7 > > Mouse 5 > > Keyboard 4 > > Scanner 3 > > > > Ant > > Ah right I see, for some reason I didn't get the 'CASE WHEN' reference > in subject, on the same page now. > > However, I have to say sorry - this feature isn't in the ORM as far as I > know. > > The ORM isn't supposed to replace SQL for every query, since > generating a less complex language to replace SQL entirely is an > exercise in futility - once you have all the features, your new > language is no less complex than the original. I guess this is one > such case. > > Cheers > > Tom > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Django users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/django-users/ZuSxc3YXA3c/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/CAFHbX1%2BFonHK4fuDUSaRbPd6%3DsWDVsisjYs%2BhUMZR7HhA60a2A%40mail.gmail.com > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CABqJoT2fHB7GO88wcxQpuxOQECsxYSf2oH3jrw_QYzWv4dRwvQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

