If you want to be able to sort by some python method you have to fetch ALL data from all tables that are used in this method. It is indeed a bad practice and so it is not encouraged in django.
The best you can do is to put your code to model's manager as a method. Model managers are often used for storing common queries and some python logic. Then you'll be able to write something like results = Person.objects.compare_to_others(gte=1).order_by ('compare_to_others') On 28 окт, 02:30, pbzRPA <pbz...@gmail.com> wrote: > Sorry I would also like to add that I would like to sort by this field > in generic views. So results = Person.objects.filter > (compare_to_others__gte = 1).order_by('compare_to_others') --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---