I've been searching the Django docs and other resources and haven't been able to find a good solution to my problem. I have a model with a remaining records and total records field, and I want to order the queryset by their quotient, remaining_records / total_records.
x = models.Data.objects.filter(date=None).extra(select={"e":"CAST(remaining_records AS FLOAT) / CAST(total_records AS FLOAT)"}).order_by('e') This is what I have right now, it works, in sqlite and I believe a minor modification changing FLOAT to DECIMAL will make it work for mysql, but I want it working with both databases. So, is there a better way to do this in Django? I know you can reference fields in a filter with F(), but I can't order by them. Any suggestions? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.