Hello, sorry about my English, but I hope that it is understandable
I am having some trouble using order_by with Django. I think it would be easier to explain what I want with an example: fx if I have this table: key ref 1 a 2 g 3 a 4 c 5 g 6 g I would like to sort it like this: key ref 2 g 5 g 6 g 1 a 3 a 4 c because there is the highest count of g's etc. My google search suggested that I should use something called annotate combined with count, but it does not work. I have tried something like: table.objects.values('key', 'ref').annotate(nr_ref=Count('ref')).order_by('nr_ref') but without any luck. -- View this message in context: http://www.nabble.com/order-by-count-tp21732508p21732508.html Sent from the django-users mailing list archive at Nabble.com. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---