1👍
You can not order by a method or property, since the ordering happens at the database, and the database does not know anything about the Django models.
You work with a query that orders by an expression with:
from django.db.models import Count
Course.objects.alias(naccount=Count('account_courses')).order_by('-naccount')
Source:stackexchange.com