1👍
✅
I would define my own sort method:
def article_sort(article_object):
return len(article_object.foos.all()) + article_object.bar.peaces
def view():
articles = sorted(Article.objects.all(), key=article_sort)
More information here
Source:stackexchange.com