[Answered ]-Selecting and sorting on unique foreign key with Django


This is not quite what you asked, but gives you the list of user IDs and their associated max speeds:

from django.db.models import Max

This might be more useful: a list of User objects with their max speeds:


Edit after comment Well, you don’t show where the time is coming from, but assuming that it’s another field on the Speed model, it’s still fairly simple:


See the documentation on ordering of annotate and filter clauses.

Leave a comment