0

I'm trying to do the following with a PostgreSQL DB:

team_updates = TeamUpdate.objects.filter(team__in = TeamStarred.objects.filter(user=request.user).values('team'))
team_updates = team_updates.order_by('-date','team__name').distinct('team__name')

This would technically solve the problem, but it causes the ordering to now be by team_name rather than date.

team_updates = TeamUpdate.objects.filter(team__in = TeamStarred.objects.filter(user=request.user).values('team'))
team_updates = team_updates.order_by('team__name', '-date').distinct('team__name')
siddhant1999
  • 65
  • 1
  • 8

0 Answers0