Performing INNER JOIN, GROUP BY, and COUNT on Django models Performing INNER JOIN, GROUP BY, and COUNT on Django models database database

Performing INNER JOIN, GROUP BY, and COUNT on Django models


If you post your models.py file I can probably give you a more precise answer, but I think what you want is the Django Aggregration API

You would use it something like this:

from django.db.models import CountUser.objects.all().annotate(bids=Count('auctionbids')).order_by('bids')